lizardwine
commited on
Commit
β’
47ae6a2
1
Parent(s):
106afa0
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,191 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
---
|
4 |
+
# π¦ Melanoma Detection Model
|
5 |
+
|
6 |
+
## π Overview
|
7 |
+
|
8 |
+
π€ **Model Name:** Melanoma Detection Model
|
9 |
+
|
10 |
+
π§ **Model Type:** Convolutional Neural Network (CNN)
|
11 |
+
|
12 |
+
π **Input:** 224x224 RGB images of skin lesions
|
13 |
+
|
14 |
+
π’ **Output:** A binary classification (Melanoma or Not Melanoma)
|
15 |
+
|
16 |
+
π― **Purpose:** To identify and classify skin lesions as melanoma or non-melanoma with high accuracy
|
17 |
+
|
18 |
+
βοΈ **Download:** Click [here](https://example.com/melanoma_detection_model/download) to download
|
19 |
+
|
20 |
+
---
|
21 |
+
|
22 |
+
## π Description
|
23 |
+
|
24 |
+
This model is designed to detect melanoma from skin lesion images. It processes input images of size 224x224 pixels and outputs a binary classification indicating whether the lesion is melanoma or not. The model is trained to differentiate between malignant melanoma and benign conditions.
|
25 |
+
|
26 |
+
---
|
27 |
+
|
28 |
+
## π Use Cases
|
29 |
+
|
30 |
+
1. **Medical Diagnosis:** π₯ Assisting dermatologists in diagnosing melanoma from images.
|
31 |
+
2. **Skin Cancer Screening:** π©Ί Enhancing early detection efforts in large-scale skin cancer screening programs.
|
32 |
+
3. **Patient Monitoring:** π©ββοΈ Helping in monitoring patients with a history of melanoma or high risk.
|
33 |
+
|
34 |
+
---
|
35 |
+
|
36 |
+
## π Performance
|
37 |
+
|
38 |
+
π **Accuracy:** ~99% on the [Skin Cancer Dataset](https://www.kaggle.com/datasets/shashanks1202/skin-cancer-dataset)
|
39 |
+
|
40 |
+
π **Latency:** Suitable for real-time analysis in clinical settings.
|
41 |
+
|
42 |
+
---
|
43 |
+
|
44 |
+
## π οΈ Technical Details
|
45 |
+
- **Based on:** [MobileNetV2](https://www.kaggle.com/models/google/mobilenet-v2)
|
46 |
+
- **Architecture:** Convolutional Neural Network (CNN)
|
47 |
+
- **Layers:** Convolutional layers, pooling layers, fully connected layers
|
48 |
+
- **Activation Functions:** ReLU, Sigmoid
|
49 |
+
|
50 |
+
---
|
51 |
+
|
52 |
+
## π₯ Input Format
|
53 |
+
|
54 |
+
- **Type:** RGB image
|
55 |
+
- **Shape:** 224x224 pixels
|
56 |
+
- **Range:** 0-1 (pixel intensity)
|
57 |
+
|
58 |
+
---
|
59 |
+
|
60 |
+
## π€ Output Format
|
61 |
+
|
62 |
+
- **Type:** Binary classification
|
63 |
+
- **Shape:** Scalar value
|
64 |
+
- **Range:** 0 (Not Melanoma), 1 (Melanoma)
|
65 |
+
|
66 |
+
---
|
67 |
+
|
68 |
+
## 𧩠Model Training
|
69 |
+
- **Dataset:** [Skin Cancer Dataset](https://www.kaggle.com/datasets/shashanks1202/skin-cancer-dataset) π
|
70 |
+
- **First step:**
|
71 |
+
- **Training Epochs:** 50
|
72 |
+
- **Batch Size:** 32
|
73 |
+
- **Optimizer:** Adam
|
74 |
+
- **Learning rate:** 1e-5
|
75 |
+
- **Layers:** Only last layer
|
76 |
+
- **Second step:**
|
77 |
+
- **Training Epochs:** 5
|
78 |
+
- **Batch Size:** 32
|
79 |
+
- **Optimizer:** Adam
|
80 |
+
- **Learning rate:** 1e-5
|
81 |
+
- **Layers:** All layers
|
82 |
+
---
|
83 |
+
|
84 |
+
## π‘ How to Use
|
85 |
+
|
86 |
+
1. **Preprocess the Image:** Resize and normalize the image to 224x224 pixels with pixel values between 0 and 1.
|
87 |
+
2. **Feed the Image:** Input the preprocessed image into the model.
|
88 |
+
3. **Interpret the Output:** Analyze the output to determine if the lesion is melanoma or not.
|
89 |
+
|
90 |
+
### Loading the Model
|
91 |
+
|
92 |
+
To use the model, first, load it using your preferred framework.
|
93 |
+
|
94 |
+
```python
|
95 |
+
import tensorflow as tf
|
96 |
+
|
97 |
+
# Load the pre-trained model
|
98 |
+
model = tf.keras.models.load_model('path/to/Melanoma-003.keras')
|
99 |
+
```
|
100 |
+
|
101 |
+
### Preprocessing the Input
|
102 |
+
|
103 |
+
Preprocess the input image to fit the model's requirements.
|
104 |
+
|
105 |
+
```python
|
106 |
+
import numpy as np
|
107 |
+
from tensorflow.keras.preprocessing import image
|
108 |
+
|
109 |
+
def preprocess_image(img_path):
|
110 |
+
# Load the image
|
111 |
+
img = image.load_img(img_path, target_size=(224, 224))
|
112 |
+
# Convert to numpy array
|
113 |
+
img_array = image.img_to_array(img)
|
114 |
+
# Normalize the image
|
115 |
+
img_array = img_array / 255.0
|
116 |
+
# Reshape to add batch dimension
|
117 |
+
img_array = np.expand_dims(img_array, axis=0)
|
118 |
+
return img_array
|
119 |
+
|
120 |
+
# Example usage
|
121 |
+
img_path = 'path/to/your/image.jpg'
|
122 |
+
processed_image = preprocess_image(img_path)
|
123 |
+
```
|
124 |
+
|
125 |
+
### Making Predictions
|
126 |
+
|
127 |
+
Use the model to predict if the lesion is melanoma.
|
128 |
+
|
129 |
+
```python
|
130 |
+
# Predict the class
|
131 |
+
prediction = model.predict(processed_image)
|
132 |
+
|
133 |
+
# Interpret the result
|
134 |
+
if prediction[0] > 0.5:
|
135 |
+
print('The lesion is classified as Melanoma.')
|
136 |
+
else:
|
137 |
+
print('The lesion is classified as Not Melanoma.')
|
138 |
+
```
|
139 |
+
|
140 |
+
### Full Example
|
141 |
+
|
142 |
+
Combining all steps into a single example.
|
143 |
+
|
144 |
+
```python
|
145 |
+
import tensorflow as tf
|
146 |
+
import numpy as np
|
147 |
+
from tensorflow.keras.preprocessing import image
|
148 |
+
|
149 |
+
# Load the pre-trained model
|
150 |
+
model = tf.keras.models.load_model('path/to/MelanomaDetectionModel.h5')
|
151 |
+
|
152 |
+
def preprocess_image(img_path):
|
153 |
+
img = image.load_img(img_path, target_size=(224, 224))
|
154 |
+
img_array = image.img_to_array(img)
|
155 |
+
img_array = img_array / 255.0
|
156 |
+
img_array = np.expand_dims(img_array, axis=0)
|
157 |
+
return img_array
|
158 |
+
|
159 |
+
img_path = 'path/to/your/image.jpg'
|
160 |
+
processed_image = preprocess_image(img_path)
|
161 |
+
|
162 |
+
prediction = model.predict(processed_image)
|
163 |
+
if prediction[0] > 0.5:
|
164 |
+
print('The lesion is classified as Melanoma.')
|
165 |
+
else:
|
166 |
+
print('The lesion is classified as Not Melanoma.')
|
167 |
+
```
|
168 |
+
|
169 |
+
---
|
170 |
+
|
171 |
+
## β οΈ Limitations
|
172 |
+
|
173 |
+
- **Image Quality:** Performance may be affected by poor-quality or low-resolution images.
|
174 |
+
- **Generalization:** Model performance may vary with images not represented in the training data.
|
175 |
+
|
176 |
+
---
|
177 |
+
|
178 |
+
## π₯ Contributors
|
179 |
+
|
180 |
+
- **Developer:** Lizardwine (x@lizardwine.com)
|
181 |
+
- **Organization:** lizardwine
|
182 |
+
- **Date:** 05/09/2024
|
183 |
+
|
184 |
+
---
|
185 |
+
|
186 |
+
## π References
|
187 |
+
|
188 |
+
- Skin Cancer Dataset: [Link](https://www.kaggle.com/datasets/shashanks1202/skin-cancer-dataset)
|
189 |
+
- MobileNetV2: [Link](https://www.kaggle.com/models/google/mobilenet-v2)
|
190 |
+
|
191 |
+
---
|