Instructions to use Wijenayake-S/dr-severity-efficientnetb0-cbam with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use Wijenayake-S/dr-severity-efficientnetb0-cbam with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://Wijenayake-S/dr-severity-efficientnetb0-cbam") - Notebooks
- Google Colab
- Kaggle
Diabetic Retinopathy Severity Grading (EfficientNetB0 + CBAM)
Five-class ETDRS severity grading from retinal fundus photographs.
Author: H.W.P.S.M. Wijenayake Project: NeuroGSD - AI Based Early Detection System for Common Eye Diseases Institution: Faculty of Information Technology, University of Moratuwa, Sri Lanka Supervisor: Dr. L. Ranathunga Domain expert: Dr. K. M. P. K. Bandara
Classes
0-No DR | 1-Mild NPDR | 2-Moderate NPDR | 3-Severe NPDR | 4-PDR
Architecture
EfficientNetB0 (ImageNet) + CBAM channel/spatial attention + global average
pooling + dropout(0.4) + softmax. Two-stage transfer learning: frozen backbone
first, then fine-tuning from block5a with BatchNorm layers held frozen.
Files
| File | Input size | Gaussian sigma |
|---|---|---|
dr_448.keras |
448x448 | 20 |
dr_224.keras |
224x224 | 10 |
config.json holds the full preprocessing specification. Preprocessing must
match exactly - the model expects Ben Graham enhanced images, not raw fundus
photographs.
Preprocessing
- Crop black border (intensity threshold 7)
- Resize to the model's input size
- Ben Graham enhancement:
addWeighted(img, 4, GaussianBlur(img, (0,0), sigma), -4, 128) - Rescale by 1/255
Results (held-out test set, n=262)
| Configuration | Accuracy | QWK | Macro-F1 |
|---|---|---|---|
| 224px argmax | 0.6718 | 0.6209 | 0.4783 |
| 448px argmax | 0.6985 | 0.7420 | 0.5700 |
| 448px + TTA (deployed) | 0.7176 | 0.7695 | 0.5722 |
| 448px + 224px ensemble | 0.7290 | 0.7848 | 0.5775 |
Per-class recall for the deployed configuration: No DR 0.876, Mild NPDR 0.122, Moderate NPDR 0.750, Severe NPDR 0.727, PDR 0.400.
Referable DR (classes 2-4 vs 0-1), 448px argmax configuration: AUC 0.942, sensitivity 0.838, specificity 0.923.
91.2% of predictions fall within one severity grade; 0.0% are misgraded by three or more.
Training data
1,744 fundus images at 512x512 native resolution, stratified 70/15/15 split (1220 / 262 / 262). Class counts: No DR 1017, Mild NPDR 270, Moderate NPDR 347, Severe NPDR 75, PDR 35. Imbalance ratio 29:1, addressed with square-root-smoothed class weights.
Limitations
- Mild NPDR recall is 0.39.
- PDR results are unreliable (n=4).
- Severe NPDR (n=11) is also low-support; its 0.727 recall is indicative only.
- Single-source dataset; generalisation across cameras and populations is untested.
- Severity labels were graded by H.W.P.S.M. Wijenayake under the domain expert's guidance and subsequently reviewed and confirmed by him - not independently double-graded.
Statistical caveats
With 262 test images the 95% confidence interval on accuracy is approximately +/-5.5 percentage points. Stratified 5-fold cross-validation over all 1,744 images is planned to give more reliable per-class estimates.
The 448px + TTA configuration was deployed rather than the marginally higher-scoring ensemble: the 1.1-point accuracy difference amounts to 3 images and falls within the confidence interval, while the ensemble doubles inference cost and requires two parallel preprocessing pipelines.
Intended use
Research and educational use only. This model is not a medical device and must not be used for clinical diagnosis. Any screening deployment would require prospective clinical validation and regulatory approval.
- Downloads last month
- -