lebiraja commited on
Commit
98b3f4b
·
verified ·
1 Parent(s): 7556457

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +151 -0
README.md ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: mit
4
+ library_name: pytorch
5
+ tags:
6
+ - medical
7
+ - vision
8
+ - disease-detection
9
+ - retinal
10
+ - ophthalmology
11
+ - multi-label-classification
12
+ ---
13
+
14
+ # Retinal Disease Classifier
15
+
16
+ A deep learning model for multi-label classification of 45 retinal diseases in fundus images using EfficientNet-B4.
17
+
18
+ ## Model Details
19
+
20
+ - **Architecture:** EfficientNet-B4 with custom classification head
21
+ - **Input:** RGB fundus images (384×384)
22
+ - **Output:** 45 disease probabilities (sigmoid-activated)
23
+ - **Training Data:** RFMiD (Retinal Fundus Multi-disease Image Dataset) - 1,920 images
24
+ - **Best Validation AUC:** 0.8204 (82.04%)
25
+
26
+ ## Supported Diseases (45 total)
27
+
28
+ Diabetic Retinopathy (DR), Age-Related Macular Degeneration (ARMD), Myopia (MH), Drusen (DN), Myopic Astigmatism (MYA), Branch Retinal Vein Occlusion (BRVO), Tessellation (TSLN), Epiretinal Membrane (ERM), Laser Scar (LS), Macular Scar (MS), Central Serous Retinopathy (CSR), Optic Disc Cupping (ODC), Central Retinal Vein Occlusion (CRVO), Tire Venture (TV), Anterior Chamber (AH), Optic Disc Pallor (ODP), Optic Disc Edema (ODE), Shunt (ST), Anterior Ischemic Optic Neuropathy (AION), Parafoveal Telangiectasia (PT), Retinal Traction (RT), Retinal Scar (RS), Corneal Reflex Shadow (CRS), Exudates (EDN), RPE Changes (RPEC), Macular Hole (MHL), Retinitis Pigmentosa (RP), Cotton Wool Spots (CWS), Conjunctival Bleed (CB), Optic Disc Pallor Margin (ODPM), Peripapillary Retinal Hemorrhage (PRH), Macular Neovascularization (MNF), Hard Retinal Exudate (HR), Central Retinal Artery Occlusion (CRAO), Temporal Disc (TD), Cystoid Macular Edema (CME), Posterior Capsular Rent (PTCR), Cotton Fiber (CF), Vitreous Hemorrhage (VH), Microaneurysms (MCA), Vitreous Synchysis (VS), Branch Retinal Artery Occlusion (BRAO), Placoid Lesion (PLQ), Hemorrhagic Pigment Epithelial Detachment (HPED), Cotton Lint (CL)
29
+
30
+ ## Usage
31
+
32
+ ### Installation
33
+
34
+ ```bash
35
+ pip install torch torchvision pillow albumentations scikit-learn
36
+ ```
37
+
38
+ ### Python API
39
+
40
+ ```python
41
+ import torch
42
+ from PIL import Image
43
+ import numpy as np
44
+ import albumentations as A
45
+ from albumentations.pytorch import ToTensorV2
46
+
47
+ # Load model from Hugging Face
48
+ from transformers import AutoModel
49
+ model = AutoModel.from_pretrained("username/retinal-disease-classifier")
50
+ model.eval()
51
+
52
+ # Prepare image
53
+ transform = A.Compose([
54
+ A.Resize(384, 384),
55
+ A.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)),
56
+ ToTensorV2(),
57
+ ])
58
+
59
+ image = np.array(Image.open("fundus.png").convert("RGB"))
60
+ tensor = transform(image=image)["image"].unsqueeze(0)
61
+
62
+ # Inference
63
+ with torch.no_grad():
64
+ logits = model(tensor)
65
+ probs = torch.sigmoid(logits)[0].cpu().numpy()
66
+
67
+ # Get predictions
68
+ disease_names = ["DR", "ARMD", "MH", ...] # 45 diseases
69
+ threshold = 0.5
70
+ detected = {name: float(prob) for name, prob in zip(disease_names, probs) if prob >= threshold}
71
+
72
+ print(f"Detected diseases: {list(detected.keys())}")
73
+ print(f"Probabilities: {detected}")
74
+ ```
75
+
76
+ ### Example Output
77
+
78
+ ```json
79
+ {
80
+ "disease_risk": true,
81
+ "predictions": {
82
+ "DR": 0.993,
83
+ "BRVO": 0.752,
84
+ "LS": 0.859,
85
+ "CRVO": 0.899
86
+ },
87
+ "detected_diseases": ["DR", "BRVO", "LS", "CRVO"],
88
+ "num_detected": 4
89
+ }
90
+ ```
91
+
92
+ ## Model Performance
93
+
94
+ | Metric | Value |
95
+ |--------|-------|
96
+ | Mean AUC-ROC | 0.8204 |
97
+ | Train Loss | 0.2118 |
98
+ | Val Loss | 0.2578 |
99
+ | Macro F1 | 0.1517 |
100
+ | Micro F1 | 0.4450 |
101
+
102
+ ## Training Details
103
+
104
+ - **Optimizer:** AdamW (differential learning rates)
105
+ - Backbone: 1e-5
106
+ - Head: 1e-4
107
+ - **Loss:** BCEWithLogitsLoss with class-weighted pos_weight
108
+ - **Scheduler:** CosineAnnealingLR (50 epochs)
109
+ - **Image Size:** 384×384 (reduced from 1424×2144)
110
+ - **Batch Size:** 5
111
+ - **Augmentations:** HFlip, VFlip, RandomBrightnessContrast, ShiftScaleRotate
112
+
113
+ ## Limitations
114
+
115
+ ⚠️ **Medical Disclaimer:**
116
+ - This model is **NOT** for clinical diagnosis
117
+ - Results should be reviewed by qualified ophthalmologists
118
+ - Use only for research and educational purposes
119
+ - Accuracy varies by disease and image quality
120
+
121
+ ## Dataset
122
+
123
+ - **Source:** RFMiD (Retinal Fundus Multi-disease Image Dataset)
124
+ - **Images:** 3,200 fundus photographs
125
+ - Training: 1,920
126
+ - Validation: 640
127
+ - Test: 640
128
+ - **Resolution:** Original ~1424×2144, resized to 384×384
129
+
130
+ ## License
131
+
132
+ MIT License - Free for research and commercial use
133
+
134
+ ## Citation
135
+
136
+ ```bibtex
137
+ @article{mindcraft2026,
138
+ title={Retinal Disease Classification with EfficientNet-B4},
139
+ author={Mindcraft},
140
+ year={2026}
141
+ }
142
+ ```
143
+
144
+ ## Support
145
+
146
+ For issues or questions, contact the model authors or visit the repository.
147
+
148
+ ---
149
+
150
+ **Last Updated:** February 22, 2026
151
+ **Model Status:** Production Ready ✅