Retinal Disease Classifier
A deep learning model for multi-label classification of 45 retinal diseases in fundus images using EfficientNet-B4.
Model Details
- Architecture: EfficientNet-B4 with custom classification head
- Input: RGB fundus images (384×384)
- Output: 45 disease probabilities (sigmoid-activated)
- Training Data: RFMiD (Retinal Fundus Multi-disease Image Dataset) - 1,920 images
- Best Validation AUC: 0.8204 (82.04%)
Supported Diseases (45 total)
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)
Usage
Installation
pip install torch torchvision pillow albumentations scikit-learn
Python API
1import torch
2from PIL import Image
3import numpy as np
4import albumentations as A
5from albumentations.pytorch import ToTensorV2
6
7# Load model from Hugging Face
8from transformers import AutoModel
9model = AutoModel.from_pretrained("username/retinal-disease-classifier")
10model.eval()
11
12# Prepare image
13transform = A.Compose([
14 A.Resize(384, 384),
15 A.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)),
16 ToTensorV2(),
17])
18
19image = np.array(Image.open("fundus.png").convert("RGB"))
20tensor = transform(image=image)["image"].unsqueeze(0)
21
22# Inference
23with torch.no_grad():
24 logits = model(tensor)
25 probs = torch.sigmoid(logits)[0].cpu().numpy()
26
27# Get predictions
28disease_names = ["DR", "ARMD", "MH", ...] # 45 diseases
29threshold = 0.5
30detected = {name: float(prob) for name, prob in zip(disease_names, probs) if prob >= threshold}
31
32print(f"Detected diseases: {list(detected.keys())}")
33print(f"Probabilities: {detected}")
Example Output
1{
2 "disease_risk": true,
3 "predictions": {
4 "DR": 0.993,
5 "BRVO": 0.752,
6 "LS": 0.859,
7 "CRVO": 0.899
8 },
9 "detected_diseases": ["DR", "BRVO", "LS", "CRVO"],
10 "num_detected": 4
11}
Model Performance
| Metric | Value |
|---|
| Mean AUC-ROC | 0.8204 |
| Train Loss | 0.2118 |
| Val Loss | 0.2578 |
| Macro F1 | 0.1517 |
| Micro F1 | 0.4450 |
Training Details
- Optimizer: AdamW (differential learning rates)
- Backbone: 1e-5
- Head: 1e-4
- Loss: BCEWithLogitsLoss with class-weighted pos_weight
- Scheduler: CosineAnnealingLR (50 epochs)
- Image Size: 384×384 (reduced from 1424×2144)
- Batch Size: 5
- Augmentations: HFlip, VFlip, RandomBrightnessContrast, ShiftScaleRotate
Limitations
⚠️ Medical Disclaimer:
- This model is NOT for clinical diagnosis
- Results should be reviewed by qualified ophthalmologists
- Use only for research and educational purposes
- Accuracy varies by disease and image quality
Dataset
- Source: RFMiD (Retinal Fundus Multi-disease Image Dataset)
- Images: 3,200 fundus photographs
- Training: 1,920
- Validation: 640
- Test: 640
- Resolution: Original ~1424×2144, resized to 384×384
License
MIT License - Free for research and commercial use
Citation
1@article{mindcraft2026,
2 title={Retinal Disease Classification with EfficientNet-B4},
3 author={Mindcraft},
4 year={2026}
5}
Support
For issues or questions, contact the model authors or visit the repository.
Last Updated: February 22, 2026
Model Status: Production Ready ✅