Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: cc-by-4.0
|
| 4 |
+
tags:
|
| 5 |
+
- image-classification
|
| 6 |
+
- medical-imaging
|
| 7 |
+
- chest-xray
|
| 8 |
+
- pneumonia
|
| 9 |
+
- efficientnet
|
| 10 |
+
- gradcam
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Pneumonia Classification Model (EfficientNet-B0)
|
| 14 |
+
|
| 15 |
+
Binary classifier for chest X-ray images: **Pneumonia** vs **Normal**.
|
| 16 |
+
|
| 17 |
+
## Architecture
|
| 18 |
+
- **Model**: EfficientNet-B0 (timm) — 4.0M parameters
|
| 19 |
+
- **Input**: 224×224 RGB (grayscale CXR → 3-channel)
|
| 20 |
+
- **Pretraining**: ImageNet
|
| 21 |
+
- **Head**: 2-class linear classifier
|
| 22 |
+
|
| 23 |
+
## Dataset
|
| 24 |
+
- **Source**: [hf-vision/chest-xray-pneumonia](https://huggingface.co/datasets/hf-vision/chest-xray-pneumonia)
|
| 25 |
+
- **Splits**: Train (5,216) | Validation (16) | Test (624)
|
| 26 |
+
- **Class imbalance**: ~1:2.9 (Normal:Pneumonia in train)
|
| 27 |
+
|
| 28 |
+
## Training Recipe
|
| 29 |
+
- **Reproducibility**: Fixed seed = 42, deterministic mode
|
| 30 |
+
- **Augmentation**: RandomHorizontalFlip, RandomRotation(15°), ColorJitter(brightness/contrast 0.05)
|
| 31 |
+
- **Normalization**: ImageNet stats
|
| 32 |
+
- **Loss**: Weighted CrossEntropy (inverse class frequency)
|
| 33 |
+
- **Sampler**: WeightedRandomSampler to balance batches
|
| 34 |
+
- **Optimizer**: AdamW (lr=1e-4, weight_decay=1e-4)
|
| 35 |
+
- **Epochs**: 5 (stratified 200+200 subset for balanced training)
|
| 36 |
+
|
| 37 |
+
## Test Performance
|
| 38 |
+
| Metric | Score |
|
| 39 |
+
|--------|-------|
|
| 40 |
+
| Accuracy | **0.8125** |
|
| 41 |
+
| Precision (Pneumonia) | **0.7910** |
|
| 42 |
+
| Recall (Pneumonia) | **0.9513** |
|
| 43 |
+
| F1-Score | **0.8638** |
|
| 44 |
+
| ROC-AUC | **0.9037** |
|
| 45 |
+
|
| 46 |
+
## Explainability
|
| 47 |
+
Grad-CAM heatmaps are included in `gradcam/` to visualize regions influencing predictions.
|
| 48 |
+
|
| 49 |
+
## Files
|
| 50 |
+
- `model.pt` — Trained model checkpoint (state_dict + config + results)
|
| 51 |
+
- `results.json` — Detailed metrics and class distribution
|
| 52 |
+
- `cm.png` — Confusion matrix
|
| 53 |
+
- `roc.png` — ROC curve
|
| 54 |
+
- `gradcam/*.png` — Grad-CAM overlays
|
| 55 |
+
|
| 56 |
+
## Limitations
|
| 57 |
+
- Trained on a small stratified subset (400 images) due to compute constraints; full-dataset training would further improve generalization.
|
| 58 |
+
- Validation set is very small (16 images); results may have high variance.
|
| 59 |
+
- No clinical validation performed; intended for research/educational use only.
|
| 60 |
+
- Class imbalance in the original dataset was addressed via sampling but may not fully represent real-world prevalence.
|