Update model card with PlasmoSENet comparison and key achievements
Browse files
README.md
CHANGED
|
@@ -1,54 +1,127 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
| 3 |
tags:
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
datasets:
|
| 10 |
-
|
| 11 |
metrics:
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
pipeline_tag: image-classification
|
|
|
|
| 17 |
---
|
| 18 |
|
| 19 |
-
#
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
## Model Details
|
| 24 |
|
| 25 |
-
|
| 26 |
-
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
## Performance
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|--------|-------|
|
| 35 |
-
| Accuracy | 97.97% |
|
| 36 |
-
| Sensitivity | 97.41% |
|
| 37 |
-
| Specificity | 98.51% |
|
| 38 |
-
| Precision | 98.43% |
|
| 39 |
-
| F1 Score | 97.92% |
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
## Usage
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
|
|
|
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
##
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
tags:
|
| 6 |
+
- malaria
|
| 7 |
+
- medical-imaging
|
| 8 |
+
- blood-smear
|
| 9 |
+
- microscopy
|
| 10 |
+
- image-classification
|
| 11 |
+
- pytorch
|
| 12 |
+
- mobilenetv2
|
| 13 |
+
- transfer-learning
|
| 14 |
datasets:
|
| 15 |
+
- NIH-Malaria-Cell-Images
|
| 16 |
metrics:
|
| 17 |
+
- accuracy
|
| 18 |
+
- f1
|
| 19 |
+
- precision
|
| 20 |
+
- recall
|
| 21 |
pipeline_tag: image-classification
|
| 22 |
+
library_name: pytorch
|
| 23 |
---
|
| 24 |
|
| 25 |
+
# MobileNetV2 (Fine-Tuned) — Malaria Parasite Detection
|
| 26 |
|
| 27 |
+
**Recommended production model.** Fine-tuned MobileNetV2 for malaria parasite detection from thin blood smear microscopy images. Achieves **97.97% test accuracy** — the highest in our model family. Part of [LocalMedScan](https://github.com/Svetozar-Technologies/LocalMedScan).
|
| 28 |
|
| 29 |
## Model Details
|
| 30 |
|
| 31 |
+
| Property | Value |
|
| 32 |
+
|:---------|:------|
|
| 33 |
+
| **Architecture** | MobileNetV2 (ImageNet pretrained, fine-tuned) |
|
| 34 |
+
| **Parameters** | ~3.4M |
|
| 35 |
+
| **Model Size** | 14 MB |
|
| 36 |
+
| **Input** | RGB 224x224 blood smear cell images |
|
| 37 |
+
| **Output** | Binary classification: Parasitized vs Uninfected |
|
| 38 |
+
| **Training** | 3-phase progressive unfreezing from ImageNet weights |
|
| 39 |
+
| **Framework** | PyTorch |
|
| 40 |
+
| **License** | MIT |
|
| 41 |
|
| 42 |
+
## Performance
|
| 43 |
|
| 44 |
+
### Test Results (NIH Malaria Dataset, 2,757 test images)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
| Metric | Without TTA | With 5-View TTA |
|
| 47 |
+
|:-------|:-----------:|:----------------:|
|
| 48 |
+
| **Accuracy** | 97.68% | **97.97%** |
|
| 49 |
+
| **Sensitivity** | 97.12% | 97.41% |
|
| 50 |
+
| **Specificity** | 98.22% | 98.51% |
|
| 51 |
+
| **Precision** | 98.19% | 98.49% |
|
| 52 |
+
| **F1 Score** | 97.65% | 97.95% |
|
| 53 |
+
|
| 54 |
+
### Comparison with PlasmoSENet
|
| 55 |
+
|
| 56 |
+
| Model | Params | Size | Accuracy (TTA) | F1 | Training |
|
| 57 |
+
|:------|:------:|:----:|:--------------:|:--:|:---------|
|
| 58 |
+
| **MobileNetV2** (this model) | 3.4M | 14 MB | **97.97%** | **97.95%** | Fine-tuned from ImageNet |
|
| 59 |
+
| [PlasmoSENet](https://huggingface.co/Svetozar1993/LocalMedScan-malaria-plasmosenet) | 10.6M | 41 MB | 96.55% | 96.47% | Trained from scratch |
|
| 60 |
+
|
| 61 |
+
MobileNetV2 outperforms PlasmoSENet by 1.42 percentage points while being 3x smaller and 3x faster. Transfer learning from ImageNet provides a decisive advantage on this dataset size (27K images).
|
| 62 |
+
|
| 63 |
+
**Use MobileNetV2 for deployment. Use PlasmoSENet for research** into domain-specific architectures or when ImageNet-free training is required.
|
| 64 |
+
|
| 65 |
+
## Key Achievements
|
| 66 |
+
|
| 67 |
+
1. **97.97% test accuracy** with 5-view TTA — exceeds most published results on this benchmark
|
| 68 |
+
2. **3-phase progressive unfreezing** prevents catastrophic forgetting while maximizing adaptation
|
| 69 |
+
3. **TransformSubset bug fix** — corrected a common PyTorch `random_split` bug where train/val/test subsets inadvertently share transforms, causing training to run without augmentation
|
| 70 |
+
4. **5-view TTA** exploiting blood cell rotational invariance (+0.29% accuracy)
|
| 71 |
+
5. **Lightweight** — 14 MB model runs on any device including mobile
|
| 72 |
+
|
| 73 |
+
## Training Details
|
| 74 |
+
|
| 75 |
+
### 3-Phase Progressive Unfreezing
|
| 76 |
+
|
| 77 |
+
- **Phase 1**: Classifier head only (frozen backbone)
|
| 78 |
+
- **Phase 2**: Last inverted residual blocks unfrozen, reduced LR
|
| 79 |
+
- **Phase 3**: Full end-to-end fine-tuning, further reduced LR
|
| 80 |
+
|
| 81 |
+
### Augmentation
|
| 82 |
+
|
| 83 |
+
Strong augmentation pipeline with RandomResizedCrop, RandomRotation(90), ColorJitter, GaussianBlur, and RandomErasing. The `TransformSubset` wrapper ensures training and validation use independent transforms.
|
| 84 |
+
|
| 85 |
+
## Dataset
|
| 86 |
+
|
| 87 |
+
**NIH Malaria Cell Images Dataset** (Rajaraman et al., 2018)
|
| 88 |
+
- 27,558 annotated cell images from Giemsa-stained thin blood smears
|
| 89 |
+
- 13,779 Parasitized + 13,779 Uninfected (balanced)
|
| 90 |
+
- Split: 80% train / 10% val / 10% test (seed=42)
|
| 91 |
|
| 92 |
## Usage
|
| 93 |
|
| 94 |
+
```python
|
| 95 |
+
import torch
|
| 96 |
+
import torchvision.models as models
|
| 97 |
+
|
| 98 |
+
# Load model
|
| 99 |
+
model = models.mobilenet_v2(weights=None)
|
| 100 |
+
model.classifier[1] = torch.nn.Linear(model.last_channel, 2)
|
| 101 |
+
state_dict = torch.load("model.pth", map_location="cpu", weights_only=True)
|
| 102 |
+
model.load_state_dict(state_dict)
|
| 103 |
+
model.eval()
|
| 104 |
+
|
| 105 |
+
# Inference
|
| 106 |
+
from torchvision import transforms
|
| 107 |
+
from PIL import Image
|
| 108 |
|
| 109 |
+
transform = transforms.Compose([
|
| 110 |
+
transforms.Resize((224, 224)),
|
| 111 |
+
transforms.ToTensor(),
|
| 112 |
+
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
|
| 113 |
+
])
|
| 114 |
|
| 115 |
+
img = Image.open("blood_smear_cell.png").convert("RGB")
|
| 116 |
+
tensor = transform(img).unsqueeze(0)
|
| 117 |
|
| 118 |
+
with torch.inference_mode():
|
| 119 |
+
probs = torch.softmax(model(tensor), dim=1)
|
| 120 |
+
# probs[0][0] = Parasitized, probs[0][1] = Uninfected
|
| 121 |
+
```
|
| 122 |
|
| 123 |
+
## Links
|
| 124 |
|
| 125 |
+
- **GitHub**: [Svetozar-Technologies/LocalMedScan](https://github.com/Svetozar-Technologies/LocalMedScan)
|
| 126 |
+
- **PlasmoSENet Model**: [Svetozar1993/LocalMedScan-malaria-plasmosenet](https://huggingface.co/Svetozar1993/LocalMedScan-malaria-plasmosenet)
|
| 127 |
+
- **Dataset**: [NIH Malaria Cell Images](https://lhncbc.nlm.nih.gov/LHC-downloads/downloads.html#malaria-datasets)
|