Diff of /readme.md [000000] .. [455abf]

Switch to unified view

a b/readme.md
1
# Breast Cancer Detection
2
 
3
 This project determines if there is breast cancer based off an ultrasound.
4
5
6
![image](https://github.com/Aidenn8/Breast-Cancer-Detection/assets/138057733/ec1322f2-0e7d-4590-926c-bc86db0215ea)
7
![image](https://github.com/Aidenn8/Breast-Cancer-Detection/assets/138057733/9dab020a-77ff-4b2c-9811-920e98fb49ba)
8
9
## Algorithm
10
11
This project uses a resnet18 model that was retrained with two different sets of data. One dataset contained images of ultrasounds that were confirmed to contain malignant breast cancer. Another dataset was consisted of ultrasounds that did not show any evidence of breast cancer. Once the model was retrained, I exported it using the ONNX format. The program uses imagenet.py to determine the whether or not breast cancer is present in an ultrasound. 
12
13
The dataset can be found here: https://www.kaggle.com/datasets/aryashah2k/breast-ultrasound-images-dataset  
14
15
16
17
18
## Running this project
19
20
21
   Setup
22
   
23
   1) Download the jetson-inference container from github to a jetson-nano: https://github.com/dusty-nv/jetson-inference
24
   3) Change directories into `jetson-inference/python/training/classification/data`
25
   4) Create a directory called "breast_cancer_detection"
26
   5) Run this command in the terminal to download the data
27
      
28
      `wget https://www.kaggle.com/datasets/aryashah2k/breast-ultrasound-images-dataset/download?datasetVersionNumber=1 -O ultrasounds.tar.gz`
29
      
30
   6) Make 3 directories called "train, "test", and "val" in the "breast_cancer_detection" directory
31
   7) Make a .txt file called "labels.txt" in the "breast_cancer_detection" directory and write down the following (in exactly that order)
32
      
33
      breast_cancer
34
      no_breast_cancer
35
36
   8) Make 2 more directories called "breast_cancer" and "no_breast_cancer" in each directory: "train", "val", and "test"
37
   9) Move around 5% of the images from the "normal" folder inside of the downloaded "ultrasounds" folder to the jetson-nano to the directory `jetson-inference/python/training/classification/data/breast_cancer_detection/test/no_breast_cancer`
38
   10) Move around 5% of the images from the "malignant" folder inside of the downloaded "ultrasounds" folder to the jetson-nano to the directory `jetson-inference/python/training/classification/data/breast_cancer_detection/test/breast_cancer`
39
   11) Move around 15%-25% of the images from the "normal" folder inside of the downloaded "ultrasounds" folder to the jetson-nano to the directory `jetson-inference/python/training/classification/data/breast_cancer_detection/val/no_breast_cancer`
40
   12) Move around 15%-25% of the images from the "malignant" folder inside of the downloaded "ultrasounds" folder to the jetson-nano to the directory `jetson-inference/python/training/classification/data/breast_cancer_detection/val/breast_cancer`
41
   13) Put the remaining images from the "normal" folder to the directory
42
       `jetson-inference/python/training/classification/data/breast_cancer_detection/train/no_breast_cancer`
43
   14) Put the remaining images from the "malignant" folder to the directory
44
       `jetson-inference/python/training/classification/data/breast_cancer_detection/train/breast_cancer`
45
   15) Make a new directory called "breast_cancer_detection" in `jetson-inference/python/training/classification/models`
46
47
48
49
50
   Execution
51
52
   1) Change directories to jetson-inference
53
   2) Type and run `./docker/run.sh` in the terminal
54
   3) Then change directories to `jetson-inference/python/training/classification`
55
   4) Now train the model by running this command in the terminal
56
      `python3 train.py --model-dir=models/breast_cancer_detection data/breast_cancer_detection --epochs=150`
57
58
      Note: This will take approximately 2 hours and 30 minutes
59
      
60
   5) Once done, export the model by running this script
61
62
      `python3 onnx_export.py --model-dir=models/breast_cancer_detection`
63
64
   7) If you are in the docker container, exit it by pressing ctrl d
65
   8) Change directories to `jetson-inference/python/training/classification`
66
   9) In the terminal enter in
67
      `NET=models/breast_cancer_detection` and
68
      `DATASET=data/breast_cancer_detection`
69
   9) Then enter in
70
       
71
`imagenet.py --model=$NET/resnet18.onnx --input_blob=input_0 --output_blob=output_0 --labels=$DATASET/labels.txt $DATASET/test/breast_cancer/malignant8.png output.jpg`
72
       
73
   10) If you look in your classification directory there will be a file called output.jpg (or whatever you named the output to be)
74
   11) Display the file to see if there is breast cancer
75
76
77
78
79
      
80
   Note:  
81
   
82
   In step 4 you can replace "malignant8.png" with any file in the breast_cancer directory and you can rename "output.jpg" to anything you want.
83
      
84
   You can also try using ultrasounds that have no breast cancer by changing "breast_cancer" in step 4 to "no_breast_cancer" and replacing      
85
   "malignant8.png" with any file in the "no_breast_cancer" directory.
86
87
   If you like, you can also upload images of ultrasounds found online to the "breast_cancer" or "no_breast_cancer" directories and try running step 4 
88
   with your own image instead of "malignant8.png" to check if there is breast cancer.
89
         
90
91
    
92
   
93
[View a video explanation here](https://www.youtube.com/watch?v=Vtg-Jqz722k)