brolaja commited on
Commit
e289520
·
verified ·
1 Parent(s): 110fe75

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +297 -0
README.md CHANGED
@@ -1,3 +1,300 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ library_name: pytorch
4
+ tags:
5
+ - image-classification
6
+ - medical-ai
7
+ - dermatology
8
+ - skin-lesion-classification
9
+ - ham10000
10
+ - efficientnetv2
11
+ - pytorch
12
+ - baseline
13
+ datasets:
14
+ - ham10000
15
+ metrics:
16
+ - accuracy
17
+ - f1
18
+ - balanced_accuracy
19
+ pipeline_tag: image-classification
20
  ---
21
+
22
+ # EfficientNetV2-S HAM10000 Image-Only Baseline
23
+
24
+ ## Model Summary
25
+
26
+ This repository contains an **EfficientNetV2-S image-only baseline** trained on the HAM10000 dataset for 7-class dermatoscopic skin-lesion classification.
27
+
28
+ The checkpoint is intended as a **research baseline** for a multimodal learning study comparing:
29
+
30
+ 1. image-only classification,
31
+ 2. metadata-only classification,
32
+ 3. late-fusion image + metadata classification.
33
+
34
+ This model uses **dermatoscopic images only**. It does **not** use patient metadata such as age, sex, or anatomical site.
35
+
36
+ > **Important:** This model is not intended for clinical diagnosis, treatment decisions, patient triage, or deployment in medical settings.
37
+
38
+ ## Intended Use
39
+
40
+ ### Intended Uses
41
+
42
+ - Research and education.
43
+ - Baseline comparison for medical image classification experiments.
44
+ - Reproducible comparison against metadata-only and late-fusion HAM10000 models.
45
+ - Portfolio demonstration of medical AI model development, class-imbalance handling, and evaluation.
46
+
47
+ ### Out-of-Scope Uses
48
+
49
+ - Clinical diagnosis or screening.
50
+ - Replacing dermatologists, clinicians, or qualified medical professionals.
51
+ - Patient-facing decision support.
52
+ - Treatment recommendation or medical reassurance.
53
+ - Real-world medical deployment without clinical validation, regulatory review, and appropriate safety controls.
54
+
55
+ ## Dataset
56
+
57
+ The model was trained and evaluated on **HAM10000**, a dermatoscopic image dataset containing common pigmented skin lesions.
58
+
59
+ The label mapping used in this project is:
60
+
61
+ | Label ID | Class Code | Lesion Type |
62
+ |---:|---|---|
63
+ | 0 | `akiec` | Actinic keratoses and intraepithelial carcinoma / Bowen's disease |
64
+ | 1 | `bcc` | Basal cell carcinoma |
65
+ | 2 | `bkl` | Benign keratosis-like lesions |
66
+ | 3 | `df` | Dermatofibroma |
67
+ | 4 | `mel` | Melanoma |
68
+ | 5 | `nv` | Melanocytic nevi |
69
+ | 6 | `vasc` | Vascular lesions |
70
+
71
+ ## Data Split
72
+
73
+ The model was trained using stratified train/validation/test splits.
74
+
75
+ | Split | Size |
76
+ |---|---:|
77
+ | Train | 7,966 |
78
+ | Validation | 996 |
79
+ | Test | 996 |
80
+
81
+ Training-set class counts:
82
+
83
+ | Label ID | Class Code | Train Count |
84
+ |---:|---|---:|
85
+ | 0 | `akiec` | 261 |
86
+ | 1 | `bcc` | 411 |
87
+ | 2 | `bkl` | 871 |
88
+ | 3 | `df` | 92 |
89
+ | 4 | `mel` | 889 |
90
+ | 5 | `nv` | 5,328 |
91
+ | 6 | `vasc` | 114 |
92
+
93
+ ## Model Architecture
94
+
95
+ - Backbone: `torchvision.models.efficientnet_v2_s`
96
+ - Pretraining: ImageNet-1K pretrained weights
97
+ - Classifier head: final linear layer replaced with a 7-class output layer
98
+ - Input modality: RGB dermatoscopic images only
99
+ - Output: 7-class lesion prediction
100
+
101
+ ## Preprocessing
102
+
103
+ All images were resized and normalized before being passed into the model.
104
+
105
+ - Input image mode: RGB
106
+ - Image size: `224 x 224`
107
+ - Normalization: ImageNet mean and standard deviation
108
+ - Mean: `[0.485, 0.456, 0.406]`
109
+ - Standard deviation: `[0.229, 0.224, 0.225]`
110
+
111
+ Training augmentations:
112
+
113
+ - Resize to `224 x 224`
114
+ - Random horizontal flip
115
+ - Random vertical flip
116
+ - Random rotation up to 15 degrees
117
+ - ImageNet normalization
118
+
119
+ Evaluation preprocessing:
120
+
121
+ - Resize to `224 x 224`
122
+ - ImageNet normalization
123
+
124
+ ## Training Details
125
+
126
+ Training setup:
127
+
128
+ | Setting | Value |
129
+ |---|---|
130
+ | Framework | PyTorch / torchvision |
131
+ | Hardware used in notebook | NVIDIA Tesla T4 |
132
+ | Batch size | 32 |
133
+ | Maximum epochs | 10 |
134
+ | Early stopping patience | 3 epochs |
135
+ | Selection metric | Validation macro-F1 |
136
+ | Loss | Class-weighted cross-entropy |
137
+ | Best epoch | 6 |
138
+ | Best validation macro-F1 | 0.8370 |
139
+ | Best validation balanced accuracy | 0.8312 |
140
+ | Best validation accuracy | 0.8785 |
141
+
142
+ Class weights were computed from the training split as:
143
+
144
+ | Label ID | Class Code | Class Weight |
145
+ |---:|---|---:|
146
+ | 0 | `akiec` | 4.3602 |
147
+ | 1 | `bcc` | 2.7689 |
148
+ | 2 | `bkl` | 1.3065 |
149
+ | 3 | `df` | 12.3696 |
150
+ | 4 | `mel` | 1.2801 |
151
+ | 5 | `nv` | 0.2136 |
152
+ | 6 | `vasc` | 9.9825 |
153
+
154
+ ## Evaluation
155
+
156
+ The model was evaluated on a held-out test set of 996 images.
157
+
158
+ ### Test Metrics
159
+
160
+ | Metric | Value |
161
+ |---|---:|
162
+ | Accuracy | 0.8665 |
163
+ | Macro-F1 | 0.8042 |
164
+ | Weighted F1 | 0.8679 |
165
+ | Balanced Accuracy | 0.8342 |
166
+
167
+ ### Per-Class Test Performance
168
+
169
+ | Label ID | Class Code | Precision | Recall | F1-score | Support |
170
+ |---:|---|---:|---:|---:|---:|
171
+ | 0 | `akiec` | 0.7778 | 0.8485 | 0.8116 | 33 |
172
+ | 1 | `bcc` | 0.7742 | 0.9231 | 0.8421 | 52 |
173
+ | 2 | `bkl` | 0.7921 | 0.7339 | 0.7619 | 109 |
174
+ | 3 | `df` | 0.8889 | 0.7273 | 0.8000 | 11 |
175
+ | 4 | `mel` | 0.6364 | 0.6937 | 0.6638 | 111 |
176
+ | 5 | `nv` | 0.9397 | 0.9129 | 0.9261 | 666 |
177
+ | 6 | `vasc` | 0.7000 | 1.0000 | 0.8235 | 14 |
178
+
179
+ ### Confusion Matrix
180
+
181
+ Rows are true labels and columns are predicted labels.
182
+
183
+ | True \\ Pred | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
184
+ |---:|---:|---:|---:|---:|---:|---:|---:|
185
+ | 0 | 28 | 3 | 0 | 1 | 0 | 1 | 0 |
186
+ | 1 | 0 | 48 | 1 | 0 | 2 | 1 | 0 |
187
+ | 2 | 5 | 3 | 80 | 0 | 10 | 10 | 1 |
188
+ | 3 | 0 | 1 | 0 | 8 | 0 | 2 | 0 |
189
+ | 4 | 1 | 0 | 6 | 0 | 77 | 25 | 2 |
190
+ | 5 | 2 | 7 | 14 | 0 | 32 | 608 | 3 |
191
+ | 6 | 0 | 0 | 0 | 0 | 0 | 0 | 14 |
192
+
193
+ ## Example Usage
194
+
195
+ This checkpoint stores the model weights for an EfficientNetV2-S architecture with a 7-class classifier head.
196
+
197
+ ```python
198
+ import torch
199
+ import torch.nn as nn
200
+ from torchvision import models, transforms
201
+ from PIL import Image
202
+
203
+ label_mapping = {
204
+ 0: "akiec",
205
+ 1: "bcc",
206
+ 2: "bkl",
207
+ 3: "df",
208
+ 4: "mel",
209
+ 5: "nv",
210
+ 6: "vasc",
211
+ }
212
+
213
+ image_size = 224
214
+ preprocess = transforms.Compose([
215
+ transforms.Resize((image_size, image_size)),
216
+ transforms.ToTensor(),
217
+ transforms.Normalize(
218
+ mean=[0.485, 0.456, 0.406],
219
+ std=[0.229, 0.224, 0.225],
220
+ ),
221
+ ])
222
+
223
+ model = models.efficientnet_v2_s(weights=None)
224
+ in_features = model.classifier[1].in_features
225
+ model.classifier[1] = nn.Linear(in_features, 7)
226
+
227
+ state_dict = torch.load("efficientnetv2s_image_only_state_dict.pt", map_location="cpu")
228
+ model.load_state_dict(state_dict)
229
+ model.eval()
230
+
231
+ image = Image.open("example.jpg").convert("RGB")
232
+ inputs = preprocess(image).unsqueeze(0)
233
+
234
+ with torch.no_grad():
235
+ logits = model(inputs)
236
+ probs = torch.softmax(logits, dim=1)
237
+ pred_id = int(probs.argmax(dim=1).item())
238
+
239
+ print(label_mapping[pred_id], float(probs[0, pred_id]))
240
+ ```
241
+
242
+ If using a full training checkpoint instead of a plain state dictionary, load the nested key:
243
+
244
+ ```python
245
+ checkpoint = torch.load("best_efficientnetv2s_image_only_ham10000.pt", map_location="cpu")
246
+ model.load_state_dict(checkpoint["model_state_dict"])
247
+ ```
248
+
249
+ ## Limitations
250
+
251
+ - The model was trained on HAM10000 and may learn dataset-specific patterns or shortcuts.
252
+ - HAM10000 is highly class-imbalanced, with melanocytic nevi (`nv`) heavily represented.
253
+ - Some classes have small test support, such as dermatofibroma (`df`) and vascular lesions (`vasc`), so per-class estimates may be unstable.
254
+ - The model does not use patient metadata such as age, sex, or anatomical site.
255
+ - Performance may vary across demographic groups, imaging devices, clinical contexts, and lesion presentations.
256
+ - The model has not been clinically validated.
257
+ - This checkpoint is a research baseline and should not be interpreted as a medical device.
258
+
259
+ ## Ethical and Safety Considerations
260
+
261
+ This model concerns medical image classification. Incorrect predictions could cause harm if used for clinical or patient-facing decisions. The model should only be used for research, education, and controlled experimentation.
262
+
263
+ Do **not** use this model to diagnose skin cancer, decide whether a lesion is benign or malignant, delay care, recommend treatment, or replace consultation with qualified medical professionals.
264
+
265
+ ## Project Context
266
+
267
+ This model is part of a broader portfolio project on multimodal HAM10000 classification. The planned comparison is:
268
+
269
+ 1. **Image-only EfficientNetV2-S baseline** — this model.
270
+ 2. **Metadata-only MLP baseline** — age, sex, and anatomical-site features only.
271
+ 3. **Late-fusion image + metadata model** — image features combined with tabular metadata.
272
+
273
+ The purpose is to test whether metadata improves classification performance beyond the image-only baseline and to document the strengths, limitations, and possible shortcut risks of metadata fusion.
274
+
275
+ ## Training Notebook
276
+
277
+ The training and evaluation workflow is documented in:
278
+
279
+ - `ham10000-image-baseline.ipynb`
280
+
281
+ ## Citation
282
+
283
+ If using this model or reproducing the project, cite the HAM10000 dataset paper:
284
+
285
+ ```bibtex
286
+ @article{tschandl2018ham10000,
287
+ title={The HAM10000 dataset, a large collection of multi-source dermatoscopic images of common pigmented skin lesions},
288
+ author={Tschandl, Philipp and Rosendahl, Cliff and Kittler, Harald},
289
+ journal={Scientific Data},
290
+ volume={5},
291
+ number={1},
292
+ pages={1--9},
293
+ year={2018},
294
+ publisher={Nature Publishing Group}
295
+ }
296
+ ```
297
+
298
+ ## License
299
+
300
+ This model repository is released under the Apache License 2.0.