Add academic polish: inference example, hparams, CITATION.cff, dataset figures, per-class CSVs
Browse files- .gitattributes +2 -0
- CITATION.cff +35 -0
- analysis/confusion_matrices_csv/cm_clip_openai.csv +11 -0
- analysis/confusion_matrices_csv/cm_densenet121.csv +11 -0
- analysis/confusion_matrices_csv/cm_dinov2_l.csv +11 -0
- analysis/confusion_matrices_csv/cm_inception_v3.csv +11 -0
- analysis/confusion_matrices_csv/cm_resnet101.csv +11 -0
- analysis/confusion_matrices_csv/cm_resnet50.csv +11 -0
- analysis/confusion_matrices_csv/cm_retfound.csv +11 -0
- analysis/confusion_matrices_csv/cm_swin_b.csv +11 -0
- analysis/confusion_matrices_csv/cm_vgg19.csv +11 -0
- analysis/per_class_metrics.csv +91 -0
- code/hparams.json +85 -0
- code/inference_example.py +85 -0
- dataset/README.md +20 -0
- dataset/class_distribution.csv +12 -0
- dataset/class_distribution.png +3 -0
- dataset/sample_grid.png +3 -0
.gitattributes
CHANGED
|
@@ -59,3 +59,5 @@ gradcam/gradcam_inception_v3.png filter=lfs diff=lfs merge=lfs -text
|
|
| 59 |
gradcam/gradcam_resnet101.png filter=lfs diff=lfs merge=lfs -text
|
| 60 |
gradcam/gradcam_resnet50.png filter=lfs diff=lfs merge=lfs -text
|
| 61 |
gradcam/gradcam_vgg19.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 59 |
gradcam/gradcam_resnet101.png filter=lfs diff=lfs merge=lfs -text
|
| 60 |
gradcam/gradcam_resnet50.png filter=lfs diff=lfs merge=lfs -text
|
| 61 |
gradcam/gradcam_vgg19.png filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
dataset/class_distribution.png filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
dataset/sample_grid.png filter=lfs diff=lfs merge=lfs -text
|
CITATION.cff
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cff-version: 1.2.0
|
| 2 |
+
message: "If you use this benchmark or any of the trained models, please cite it as below."
|
| 3 |
+
title: "Fundus 9-Model Benchmark: VGG19, ResNet50/101, DenseNet121, InceptionV3, Swin-B, CLIP, DINOv2-L, RETFound"
|
| 4 |
+
authors:
|
| 5 |
+
- family-names: Katiyo
|
| 6 |
+
given-names: Daryl Panashe
|
| 7 |
+
affiliation: Xidian University
|
| 8 |
+
version: "1.0.0"
|
| 9 |
+
date-released: 2026-05-26
|
| 10 |
+
license: Apache-2.0
|
| 11 |
+
type: software
|
| 12 |
+
repository-code: "https://huggingface.co/DoB24/fundus-9model-benchmark"
|
| 13 |
+
url: "https://huggingface.co/DoB24/fundus-9model-benchmark"
|
| 14 |
+
keywords:
|
| 15 |
+
- fundus
|
| 16 |
+
- retinal-imaging
|
| 17 |
+
- medical-image-classification
|
| 18 |
+
- deep-learning
|
| 19 |
+
- benchmark
|
| 20 |
+
- RETFound
|
| 21 |
+
- DINOv2
|
| 22 |
+
- vision-transformer
|
| 23 |
+
abstract: >
|
| 24 |
+
A reproducible 10-class fundus disease classification benchmark with nine deep
|
| 25 |
+
models (VGG19, ResNet50, ResNet101, DenseNet121, InceptionV3, Swin-B, CLIP-ViT-B/16,
|
| 26 |
+
DINOv2-L, RETFound) trained under an identical v2 protocol (CLAHE + RandAugment +
|
| 27 |
+
WeightedRandomSampler + MixUp/CutMix + 6-view TTA) on a pHash-grouped 5-fold split
|
| 28 |
+
of the Mendeley 10-class fundus dataset.
|
| 29 |
+
references:
|
| 30 |
+
- type: dataset
|
| 31 |
+
title: "Eye disease image dataset"
|
| 32 |
+
authors:
|
| 33 |
+
- family-names: Khaled
|
| 34 |
+
given-names: Mohammad
|
| 35 |
+
url: "https://data.mendeley.com/datasets/s9bfhswzjb/1"
|
analysis/confusion_matrices_csv/cm_clip_openai.csv
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
,Central Serous Chorioretinopathy [Color Fundus],Diabetic Retinopathy,Disc Edema,Glaucoma,Healthy,Macular Scar,Myopia,Pterygium,Retinal Detachment,Retinitis Pigmentosa
|
| 2 |
+
Central Serous Chorioretinopathy [Color Fundus],104,0,0,1,0,3,0,0,0,0
|
| 3 |
+
Diabetic Retinopathy,5,687,10,6,0,20,2,0,2,1
|
| 4 |
+
Disc Edema,0,0,137,0,0,0,0,0,0,0
|
| 5 |
+
Glaucoma,2,5,1,389,103,21,85,0,1,2
|
| 6 |
+
Healthy,4,5,0,44,475,8,12,0,0,0
|
| 7 |
+
Macular Scar,3,9,3,10,13,290,4,0,0,2
|
| 8 |
+
Myopia,0,0,0,31,6,11,386,0,0,6
|
| 9 |
+
Pterygium,0,0,0,0,0,0,0,17,0,0
|
| 10 |
+
Retinal Detachment,0,0,0,0,0,0,0,0,127,0
|
| 11 |
+
Retinitis Pigmentosa,0,0,0,0,0,0,0,0,0,155
|
analysis/confusion_matrices_csv/cm_densenet121.csv
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
,Central Serous Chorioretinopathy [Color Fundus],Diabetic Retinopathy,Disc Edema,Glaucoma,Healthy,Macular Scar,Myopia,Pterygium,Retinal Detachment,Retinitis Pigmentosa
|
| 2 |
+
Central Serous Chorioretinopathy [Color Fundus],101,0,0,1,0,6,0,0,0,0
|
| 3 |
+
Diabetic Retinopathy,5,700,10,4,0,11,1,0,1,1
|
| 4 |
+
Disc Edema,0,0,137,0,0,0,0,0,0,0
|
| 5 |
+
Glaucoma,2,4,1,494,55,12,39,0,0,2
|
| 6 |
+
Healthy,3,0,0,55,467,11,12,0,0,0
|
| 7 |
+
Macular Scar,2,1,3,14,5,303,4,0,0,2
|
| 8 |
+
Myopia,0,3,0,34,9,9,379,0,0,6
|
| 9 |
+
Pterygium,0,0,0,0,0,0,0,17,0,0
|
| 10 |
+
Retinal Detachment,0,0,0,0,0,0,0,0,127,0
|
| 11 |
+
Retinitis Pigmentosa,0,0,0,0,0,0,0,0,0,155
|
analysis/confusion_matrices_csv/cm_dinov2_l.csv
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
,Central Serous Chorioretinopathy [Color Fundus],Diabetic Retinopathy,Disc Edema,Glaucoma,Healthy,Macular Scar,Myopia,Pterygium,Retinal Detachment,Retinitis Pigmentosa
|
| 2 |
+
Central Serous Chorioretinopathy [Color Fundus],102,0,0,0,0,6,0,0,0,0
|
| 3 |
+
Diabetic Retinopathy,5,707,5,4,0,10,0,0,1,1
|
| 4 |
+
Disc Edema,0,0,136,0,0,1,0,0,0,0
|
| 5 |
+
Glaucoma,2,5,1,487,68,12,31,0,1,2
|
| 6 |
+
Healthy,3,0,0,40,487,10,8,0,0,0
|
| 7 |
+
Macular Scar,2,4,3,13,2,303,5,0,0,2
|
| 8 |
+
Myopia,0,5,0,51,22,6,350,0,0,6
|
| 9 |
+
Pterygium,0,0,0,0,0,0,0,17,0,0
|
| 10 |
+
Retinal Detachment,0,0,0,0,0,0,0,0,127,0
|
| 11 |
+
Retinitis Pigmentosa,0,0,0,0,0,0,0,0,0,155
|
analysis/confusion_matrices_csv/cm_inception_v3.csv
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
,Central Serous Chorioretinopathy [Color Fundus],Diabetic Retinopathy,Disc Edema,Glaucoma,Healthy,Macular Scar,Myopia,Pterygium,Retinal Detachment,Retinitis Pigmentosa
|
| 2 |
+
Central Serous Chorioretinopathy [Color Fundus],102,0,0,0,0,6,0,0,0,0
|
| 3 |
+
Diabetic Retinopathy,5,701,10,4,0,10,1,0,1,1
|
| 4 |
+
Disc Edema,0,0,137,0,0,0,0,0,0,0
|
| 5 |
+
Glaucoma,2,6,1,492,60,11,35,0,0,2
|
| 6 |
+
Healthy,3,0,0,59,463,13,10,0,0,0
|
| 7 |
+
Macular Scar,2,3,3,12,2,304,6,0,0,2
|
| 8 |
+
Myopia,0,4,0,47,12,7,364,0,0,6
|
| 9 |
+
Pterygium,0,0,0,0,0,0,0,17,0,0
|
| 10 |
+
Retinal Detachment,0,0,0,0,0,0,0,0,127,0
|
| 11 |
+
Retinitis Pigmentosa,0,0,0,0,0,0,0,0,0,155
|
analysis/confusion_matrices_csv/cm_resnet101.csv
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
,Central Serous Chorioretinopathy [Color Fundus],Diabetic Retinopathy,Disc Edema,Glaucoma,Healthy,Macular Scar,Myopia,Pterygium,Retinal Detachment,Retinitis Pigmentosa
|
| 2 |
+
Central Serous Chorioretinopathy [Color Fundus],102,0,0,1,0,5,0,0,0,0
|
| 3 |
+
Diabetic Retinopathy,5,702,6,5,0,11,2,0,1,1
|
| 4 |
+
Disc Edema,0,1,136,0,0,0,0,0,0,0
|
| 5 |
+
Glaucoma,2,6,1,478,69,15,36,0,0,2
|
| 6 |
+
Healthy,3,0,0,53,473,9,10,0,0,0
|
| 7 |
+
Macular Scar,2,6,3,13,2,303,3,0,0,2
|
| 8 |
+
Myopia,0,4,0,34,16,10,370,0,0,6
|
| 9 |
+
Pterygium,0,0,0,0,0,0,0,17,0,0
|
| 10 |
+
Retinal Detachment,0,0,0,0,0,0,0,0,127,0
|
| 11 |
+
Retinitis Pigmentosa,0,0,0,0,0,0,0,0,0,155
|
analysis/confusion_matrices_csv/cm_resnet50.csv
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
,Central Serous Chorioretinopathy [Color Fundus],Diabetic Retinopathy,Disc Edema,Glaucoma,Healthy,Macular Scar,Myopia,Pterygium,Retinal Detachment,Retinitis Pigmentosa
|
| 2 |
+
Central Serous Chorioretinopathy [Color Fundus],102,0,0,0,0,6,0,0,0,0
|
| 3 |
+
Diabetic Retinopathy,5,699,10,5,0,11,1,0,1,1
|
| 4 |
+
Disc Edema,0,1,136,0,0,0,0,0,0,0
|
| 5 |
+
Glaucoma,2,6,1,486,70,12,30,0,0,2
|
| 6 |
+
Healthy,3,0,0,50,475,10,10,0,0,0
|
| 7 |
+
Macular Scar,2,3,3,15,5,299,5,0,0,2
|
| 8 |
+
Myopia,0,3,0,52,10,7,362,0,0,6
|
| 9 |
+
Pterygium,0,0,0,0,0,0,0,17,0,0
|
| 10 |
+
Retinal Detachment,0,0,0,0,0,0,0,0,127,0
|
| 11 |
+
Retinitis Pigmentosa,0,0,0,0,0,0,0,0,0,155
|
analysis/confusion_matrices_csv/cm_retfound.csv
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
,Central Serous Chorioretinopathy [Color Fundus],Diabetic Retinopathy,Disc Edema,Glaucoma,Healthy,Macular Scar,Myopia,Pterygium,Retinal Detachment,Retinitis Pigmentosa
|
| 2 |
+
Central Serous Chorioretinopathy [Color Fundus],101,0,0,1,0,6,0,0,0,0
|
| 3 |
+
Diabetic Retinopathy,5,688,13,5,0,18,2,0,1,1
|
| 4 |
+
Disc Edema,0,4,132,0,0,0,1,0,0,0
|
| 5 |
+
Glaucoma,3,6,1,410,77,26,82,0,2,2
|
| 6 |
+
Healthy,7,4,2,82,426,6,21,0,0,0
|
| 7 |
+
Macular Scar,11,6,4,11,16,268,14,0,1,3
|
| 8 |
+
Myopia,0,0,0,56,7,4,367,0,0,6
|
| 9 |
+
Pterygium,0,0,0,0,0,0,0,17,0,0
|
| 10 |
+
Retinal Detachment,0,0,0,0,0,0,0,0,127,0
|
| 11 |
+
Retinitis Pigmentosa,0,0,0,0,0,0,0,0,0,155
|
analysis/confusion_matrices_csv/cm_swin_b.csv
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
,Central Serous Chorioretinopathy [Color Fundus],Diabetic Retinopathy,Disc Edema,Glaucoma,Healthy,Macular Scar,Myopia,Pterygium,Retinal Detachment,Retinitis Pigmentosa
|
| 2 |
+
Central Serous Chorioretinopathy [Color Fundus],103,0,0,0,0,5,0,0,0,0
|
| 3 |
+
Diabetic Retinopathy,5,698,10,5,0,10,3,0,1,1
|
| 4 |
+
Disc Edema,0,0,137,0,0,0,0,0,0,0
|
| 5 |
+
Glaucoma,2,5,1,454,85,15,44,0,1,2
|
| 6 |
+
Healthy,5,4,0,66,458,4,11,0,0,0
|
| 7 |
+
Macular Scar,4,4,3,14,6,291,10,0,0,2
|
| 8 |
+
Myopia,0,0,0,73,15,0,346,0,0,6
|
| 9 |
+
Pterygium,0,0,0,0,0,0,0,17,0,0
|
| 10 |
+
Retinal Detachment,0,0,0,0,0,0,0,0,127,0
|
| 11 |
+
Retinitis Pigmentosa,0,0,0,0,0,0,0,0,0,155
|
analysis/confusion_matrices_csv/cm_vgg19.csv
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
,Central Serous Chorioretinopathy [Color Fundus],Diabetic Retinopathy,Disc Edema,Glaucoma,Healthy,Macular Scar,Myopia,Pterygium,Retinal Detachment,Retinitis Pigmentosa
|
| 2 |
+
Central Serous Chorioretinopathy [Color Fundus],105,0,0,1,0,2,0,0,0,0
|
| 3 |
+
Diabetic Retinopathy,5,698,10,6,0,10,2,0,1,1
|
| 4 |
+
Disc Edema,0,0,137,0,0,0,0,0,0,0
|
| 5 |
+
Glaucoma,2,3,1,470,76,16,39,0,0,2
|
| 6 |
+
Healthy,3,0,0,51,473,9,12,0,0,0
|
| 7 |
+
Macular Scar,3,4,3,13,6,298,5,0,0,2
|
| 8 |
+
Myopia,0,0,0,30,12,7,385,0,0,6
|
| 9 |
+
Pterygium,0,0,0,0,0,0,0,17,0,0
|
| 10 |
+
Retinal Detachment,0,0,0,0,0,0,0,0,127,0
|
| 11 |
+
Retinitis Pigmentosa,0,0,0,0,0,0,0,0,0,155
|
analysis/per_class_metrics.csv
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
model,class,precision,recall,f1,support
|
| 2 |
+
vgg19,Central Serous Chorioretinopathy [Color Fundus],0.8898,0.9722,0.9292,108
|
| 3 |
+
vgg19,Diabetic Retinopathy,0.9901,0.9523,0.9708,733
|
| 4 |
+
vgg19,Disc Edema,0.9073,1.0000,0.9514,137
|
| 5 |
+
vgg19,Glaucoma,0.8231,0.7718,0.7966,609
|
| 6 |
+
vgg19,Healthy,0.8342,0.8631,0.8484,548
|
| 7 |
+
vgg19,Macular Scar,0.8713,0.8922,0.8817,334
|
| 8 |
+
vgg19,Myopia,0.8691,0.8750,0.8720,440
|
| 9 |
+
vgg19,Pterygium,1.0000,1.0000,1.0000,17
|
| 10 |
+
vgg19,Retinal Detachment,0.9922,1.0000,0.9961,127
|
| 11 |
+
vgg19,Retinitis Pigmentosa,0.9337,1.0000,0.9657,155
|
| 12 |
+
resnet50,Central Serous Chorioretinopathy [Color Fundus],0.8947,0.9444,0.9189,108
|
| 13 |
+
resnet50,Diabetic Retinopathy,0.9817,0.9536,0.9675,733
|
| 14 |
+
resnet50,Disc Edema,0.9067,0.9927,0.9477,137
|
| 15 |
+
resnet50,Glaucoma,0.7993,0.7980,0.7987,609
|
| 16 |
+
resnet50,Healthy,0.8482,0.8668,0.8574,548
|
| 17 |
+
resnet50,Macular Scar,0.8667,0.8952,0.8807,334
|
| 18 |
+
resnet50,Myopia,0.8873,0.8227,0.8538,440
|
| 19 |
+
resnet50,Pterygium,1.0000,1.0000,1.0000,17
|
| 20 |
+
resnet50,Retinal Detachment,0.9922,1.0000,0.9961,127
|
| 21 |
+
resnet50,Retinitis Pigmentosa,0.9337,1.0000,0.9657,155
|
| 22 |
+
resnet101,Central Serous Chorioretinopathy [Color Fundus],0.8947,0.9444,0.9189,108
|
| 23 |
+
resnet101,Diabetic Retinopathy,0.9764,0.9577,0.9669,733
|
| 24 |
+
resnet101,Disc Edema,0.9315,0.9927,0.9611,137
|
| 25 |
+
resnet101,Glaucoma,0.8185,0.7849,0.8013,609
|
| 26 |
+
resnet101,Healthy,0.8446,0.8631,0.8538,548
|
| 27 |
+
resnet101,Macular Scar,0.8584,0.9072,0.8821,334
|
| 28 |
+
resnet101,Myopia,0.8789,0.8409,0.8595,440
|
| 29 |
+
resnet101,Pterygium,1.0000,1.0000,1.0000,17
|
| 30 |
+
resnet101,Retinal Detachment,0.9922,1.0000,0.9961,127
|
| 31 |
+
resnet101,Retinitis Pigmentosa,0.9337,1.0000,0.9657,155
|
| 32 |
+
densenet121,Central Serous Chorioretinopathy [Color Fundus],0.8938,0.9352,0.9140,108
|
| 33 |
+
densenet121,Diabetic Retinopathy,0.9887,0.9550,0.9715,733
|
| 34 |
+
densenet121,Disc Edema,0.9073,1.0000,0.9514,137
|
| 35 |
+
densenet121,Glaucoma,0.8206,0.8112,0.8159,609
|
| 36 |
+
densenet121,Healthy,0.8713,0.8522,0.8616,548
|
| 37 |
+
densenet121,Macular Scar,0.8608,0.9072,0.8834,334
|
| 38 |
+
densenet121,Myopia,0.8713,0.8614,0.8663,440
|
| 39 |
+
densenet121,Pterygium,1.0000,1.0000,1.0000,17
|
| 40 |
+
densenet121,Retinal Detachment,0.9922,1.0000,0.9961,127
|
| 41 |
+
densenet121,Retinitis Pigmentosa,0.9337,1.0000,0.9657,155
|
| 42 |
+
inception_v3,Central Serous Chorioretinopathy [Color Fundus],0.8947,0.9444,0.9189,108
|
| 43 |
+
inception_v3,Diabetic Retinopathy,0.9818,0.9563,0.9689,733
|
| 44 |
+
inception_v3,Disc Edema,0.9073,1.0000,0.9514,137
|
| 45 |
+
inception_v3,Glaucoma,0.8013,0.8079,0.8046,609
|
| 46 |
+
inception_v3,Healthy,0.8622,0.8449,0.8535,548
|
| 47 |
+
inception_v3,Macular Scar,0.8661,0.9102,0.8876,334
|
| 48 |
+
inception_v3,Myopia,0.8750,0.8273,0.8505,440
|
| 49 |
+
inception_v3,Pterygium,1.0000,1.0000,1.0000,17
|
| 50 |
+
inception_v3,Retinal Detachment,0.9922,1.0000,0.9961,127
|
| 51 |
+
inception_v3,Retinitis Pigmentosa,0.9337,1.0000,0.9657,155
|
| 52 |
+
swin_b,Central Serous Chorioretinopathy [Color Fundus],0.8655,0.9537,0.9075,108
|
| 53 |
+
swin_b,Diabetic Retinopathy,0.9817,0.9523,0.9668,733
|
| 54 |
+
swin_b,Disc Edema,0.9073,1.0000,0.9514,137
|
| 55 |
+
swin_b,Glaucoma,0.7418,0.7455,0.7437,609
|
| 56 |
+
swin_b,Healthy,0.8121,0.8358,0.8237,548
|
| 57 |
+
swin_b,Macular Scar,0.8954,0.8713,0.8832,334
|
| 58 |
+
swin_b,Myopia,0.8357,0.7864,0.8103,440
|
| 59 |
+
swin_b,Pterygium,1.0000,1.0000,1.0000,17
|
| 60 |
+
swin_b,Retinal Detachment,0.9845,1.0000,0.9922,127
|
| 61 |
+
swin_b,Retinitis Pigmentosa,0.9337,1.0000,0.9657,155
|
| 62 |
+
clip_openai,Central Serous Chorioretinopathy [Color Fundus],0.8814,0.9630,0.9204,108
|
| 63 |
+
clip_openai,Diabetic Retinopathy,0.9731,0.9372,0.9548,733
|
| 64 |
+
clip_openai,Disc Edema,0.9073,1.0000,0.9514,137
|
| 65 |
+
clip_openai,Glaucoma,0.8087,0.6388,0.7138,609
|
| 66 |
+
clip_openai,Healthy,0.7956,0.8668,0.8297,548
|
| 67 |
+
clip_openai,Macular Scar,0.8215,0.8683,0.8443,334
|
| 68 |
+
clip_openai,Myopia,0.7894,0.8773,0.8310,440
|
| 69 |
+
clip_openai,Pterygium,1.0000,1.0000,1.0000,17
|
| 70 |
+
clip_openai,Retinal Detachment,0.9769,1.0000,0.9883,127
|
| 71 |
+
clip_openai,Retinitis Pigmentosa,0.9337,1.0000,0.9657,155
|
| 72 |
+
dinov2_l,Central Serous Chorioretinopathy [Color Fundus],0.8947,0.9444,0.9189,108
|
| 73 |
+
dinov2_l,Diabetic Retinopathy,0.9806,0.9645,0.9725,733
|
| 74 |
+
dinov2_l,Disc Edema,0.9379,0.9927,0.9645,137
|
| 75 |
+
dinov2_l,Glaucoma,0.8185,0.7997,0.8090,609
|
| 76 |
+
dinov2_l,Healthy,0.8411,0.8887,0.8642,548
|
| 77 |
+
dinov2_l,Macular Scar,0.8707,0.9072,0.8886,334
|
| 78 |
+
dinov2_l,Myopia,0.8883,0.7955,0.8393,440
|
| 79 |
+
dinov2_l,Pterygium,1.0000,1.0000,1.0000,17
|
| 80 |
+
dinov2_l,Retinal Detachment,0.9845,1.0000,0.9922,127
|
| 81 |
+
dinov2_l,Retinitis Pigmentosa,0.9337,1.0000,0.9657,155
|
| 82 |
+
retfound,Central Serous Chorioretinopathy [Color Fundus],0.7953,0.9352,0.8596,108
|
| 83 |
+
retfound,Diabetic Retinopathy,0.9718,0.9386,0.9549,733
|
| 84 |
+
retfound,Disc Edema,0.8684,0.9635,0.9135,137
|
| 85 |
+
retfound,Glaucoma,0.7257,0.6732,0.6985,609
|
| 86 |
+
retfound,Healthy,0.8099,0.7774,0.7933,548
|
| 87 |
+
retfound,Macular Scar,0.8171,0.8024,0.8097,334
|
| 88 |
+
retfound,Myopia,0.7536,0.8341,0.7918,440
|
| 89 |
+
retfound,Pterygium,1.0000,1.0000,1.0000,17
|
| 90 |
+
retfound,Retinal Detachment,0.9695,1.0000,0.9845,127
|
| 91 |
+
retfound,Retinitis Pigmentosa,0.9281,1.0000,0.9627,155
|
code/hparams.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"common": {
|
| 3 |
+
"image_size": 224,
|
| 4 |
+
"batch_size": 32,
|
| 5 |
+
"optimizer": "AdamW",
|
| 6 |
+
"weight_decay": 0.0001,
|
| 7 |
+
"lr_schedule": "warmup-cosine",
|
| 8 |
+
"warmup_epochs": 3,
|
| 9 |
+
"total_epochs": 60,
|
| 10 |
+
"early_stopping_patience": 12,
|
| 11 |
+
"label_smoothing": 0.1,
|
| 12 |
+
"loss": "CrossEntropyLoss (label-smoothed)",
|
| 13 |
+
"mixup_alpha": 0.2,
|
| 14 |
+
"cutmix_alpha": 1.0,
|
| 15 |
+
"mixup_cutmix_prob": 0.7,
|
| 16 |
+
"sampler": "WeightedRandomSampler (inverse-frequency)",
|
| 17 |
+
"augmentations": [
|
| 18 |
+
"CLAHE (cliplimit=2.0, tilegrid=8x8)",
|
| 19 |
+
"RandAugment (n=2, m=9)",
|
| 20 |
+
"RandomHorizontalFlip(0.5)",
|
| 21 |
+
"RandomVerticalFlip(0.2)",
|
| 22 |
+
"ColorJitter(brightness=0.2, contrast=0.2, saturation=0.2)",
|
| 23 |
+
"RandomErasing(p=0.25)",
|
| 24 |
+
"Normalize(ImageNet stats)"
|
| 25 |
+
],
|
| 26 |
+
"tta": {
|
| 27 |
+
"crops": 6,
|
| 28 |
+
"ops": [
|
| 29 |
+
"centre",
|
| 30 |
+
"horizontal-flip",
|
| 31 |
+
"vertical-flip",
|
| 32 |
+
"rot90",
|
| 33 |
+
"rot180",
|
| 34 |
+
"rot270"
|
| 35 |
+
]
|
| 36 |
+
},
|
| 37 |
+
"amp": "fp16",
|
| 38 |
+
"split": "Group-aware StratifiedGroupKFold(5) on pHash groups, fold 0 = test"
|
| 39 |
+
},
|
| 40 |
+
"per_model_learning_rate": {
|
| 41 |
+
"vgg19": 0.0001,
|
| 42 |
+
"resnet50": 0.0001,
|
| 43 |
+
"resnet101": 0.0001,
|
| 44 |
+
"densenet121": 0.0001,
|
| 45 |
+
"inception_v3": 0.0001,
|
| 46 |
+
"swin_b": 5e-05,
|
| 47 |
+
"clip_openai": 5e-05,
|
| 48 |
+
"dinov2_l": {
|
| 49 |
+
"stage1_head_only_lr": 0.001,
|
| 50 |
+
"stage1_epochs": 20,
|
| 51 |
+
"stage2_full_lr": 1e-05,
|
| 52 |
+
"stage2_epochs": 40
|
| 53 |
+
},
|
| 54 |
+
"retfound": {
|
| 55 |
+
"stage1_head_only_lr": 0.001,
|
| 56 |
+
"stage1_epochs": 20,
|
| 57 |
+
"stage2_full_lr": 1e-05,
|
| 58 |
+
"stage2_epochs": 40
|
| 59 |
+
}
|
| 60 |
+
},
|
| 61 |
+
"ensemble": {
|
| 62 |
+
"method": "soft-vote",
|
| 63 |
+
"weights": "per-model validation F1, L1-normalised",
|
| 64 |
+
"calibration": "per-model temperature scaling on validation set",
|
| 65 |
+
"conformal": "Mondrian (class-conditioned) split-conformal at 90% coverage"
|
| 66 |
+
},
|
| 67 |
+
"hardware": {
|
| 68 |
+
"gpu": "NVIDIA Tesla T4 (16 GB)",
|
| 69 |
+
"cuda": "12.8",
|
| 70 |
+
"pytorch": "2.11.0+cu128",
|
| 71 |
+
"approx_gpu_hours": {
|
| 72 |
+
"vgg19": 2.5,
|
| 73 |
+
"resnet50": 2.3,
|
| 74 |
+
"resnet101": 3.1,
|
| 75 |
+
"densenet121": 2.8,
|
| 76 |
+
"inception_v3": 2.2,
|
| 77 |
+
"swin_b": 4.5,
|
| 78 |
+
"clip_openai": 3.8,
|
| 79 |
+
"dinov2_l": 11.2,
|
| 80 |
+
"retfound": 9.4,
|
| 81 |
+
"ensemble_and_stats": 0.3,
|
| 82 |
+
"total": 42.1
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
}
|
code/inference_example.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Minimal inference example for DoB24/fundus-9model-benchmark.
|
| 2 |
+
|
| 3 |
+
Loads one of the 9 trained checkpoints, applies the same preprocessing used
|
| 4 |
+
during evaluation, and predicts a class for a single fundus image.
|
| 5 |
+
|
| 6 |
+
Usage:
|
| 7 |
+
python inference_example.py path/to/image.jpg --model densenet121
|
| 8 |
+
"""
|
| 9 |
+
from __future__ import annotations
|
| 10 |
+
import argparse, json
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
import torch
|
| 13 |
+
import torch.nn.functional as F
|
| 14 |
+
from torchvision import transforms
|
| 15 |
+
from PIL import Image
|
| 16 |
+
import timm
|
| 17 |
+
from huggingface_hub import hf_hub_download
|
| 18 |
+
|
| 19 |
+
REPO = "DoB24/fundus-9model-benchmark"
|
| 20 |
+
CLASSES = [
|
| 21 |
+
"Central Serous Chorioretinopathy",
|
| 22 |
+
"Diabetic Retinopathy", "Disc Edema", "Glaucoma", "Healthy",
|
| 23 |
+
"Macular Scar", "Myopia", "Pterygium",
|
| 24 |
+
"Retinal Detachment", "Retinitis Pigmentosa",
|
| 25 |
+
]
|
| 26 |
+
# Map repo-name to timm model id
|
| 27 |
+
TIMM_ID = {
|
| 28 |
+
"vgg19": "vgg19", "resnet50": "resnet50", "resnet101": "resnet101",
|
| 29 |
+
"densenet121": "densenet121", "inception_v3": "inception_v3",
|
| 30 |
+
"swin_b": "swin_base_patch4_window7_224",
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
def load_model(name: str, num_classes: int = 10):
|
| 34 |
+
weights = hf_hub_download(REPO, f"weights/{name}_best.pth")
|
| 35 |
+
if name in TIMM_ID:
|
| 36 |
+
model = timm.create_model(TIMM_ID[name], pretrained=False, num_classes=num_classes)
|
| 37 |
+
if name == "inception_v3":
|
| 38 |
+
model = timm.create_model("inception_v3", pretrained=False,
|
| 39 |
+
num_classes=num_classes, aux_logits=False)
|
| 40 |
+
elif name == "clip_openai":
|
| 41 |
+
import open_clip
|
| 42 |
+
model, _, _ = open_clip.create_model_and_transforms("ViT-B-16", pretrained=None)
|
| 43 |
+
model.visual.proj = None
|
| 44 |
+
model = torch.nn.Sequential(model.visual, torch.nn.Linear(768, num_classes))
|
| 45 |
+
elif name == "dinov2_l":
|
| 46 |
+
model = torch.hub.load("facebookresearch/dinov2", "dinov2_vitl14")
|
| 47 |
+
model = torch.nn.Sequential(model, torch.nn.Linear(1024, num_classes))
|
| 48 |
+
elif name == "retfound":
|
| 49 |
+
model = timm.create_model("vit_large_patch16_224", pretrained=False,
|
| 50 |
+
num_classes=num_classes)
|
| 51 |
+
else:
|
| 52 |
+
raise ValueError(f"Unknown model: {name}")
|
| 53 |
+
sd = torch.load(weights, map_location="cpu", weights_only=False)
|
| 54 |
+
if isinstance(sd, dict) and "state_dict" in sd:
|
| 55 |
+
sd = sd["state_dict"]
|
| 56 |
+
model.load_state_dict(sd, strict=False)
|
| 57 |
+
model.eval()
|
| 58 |
+
return model
|
| 59 |
+
|
| 60 |
+
def preprocess(img_path: str) -> torch.Tensor:
|
| 61 |
+
tf = transforms.Compose([
|
| 62 |
+
transforms.Resize((224, 224)),
|
| 63 |
+
transforms.ToTensor(),
|
| 64 |
+
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
|
| 65 |
+
])
|
| 66 |
+
return tf(Image.open(img_path).convert("RGB")).unsqueeze(0)
|
| 67 |
+
|
| 68 |
+
def main():
|
| 69 |
+
ap = argparse.ArgumentParser()
|
| 70 |
+
ap.add_argument("image")
|
| 71 |
+
ap.add_argument("--model", default="densenet121",
|
| 72 |
+
choices=list(TIMM_ID) + ["clip_openai", "dinov2_l", "retfound"])
|
| 73 |
+
args = ap.parse_args()
|
| 74 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 75 |
+
model = load_model(args.model).to(device)
|
| 76 |
+
x = preprocess(args.image).to(device)
|
| 77 |
+
with torch.no_grad():
|
| 78 |
+
probs = F.softmax(model(x), dim=1)[0].cpu().numpy()
|
| 79 |
+
order = probs.argsort()[::-1]
|
| 80 |
+
print(f"\nTop-3 predictions for {args.image} using {args.model}:")
|
| 81 |
+
for i in order[:3]:
|
| 82 |
+
print(f" {CLASSES[i]:40s} {probs[i]*100:5.2f} %")
|
| 83 |
+
|
| 84 |
+
if __name__ == "__main__":
|
| 85 |
+
main()
|
dataset/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Dataset Figures
|
| 2 |
+
|
| 3 |
+
- `class_distribution.png` — bar chart of per-class counts (original vs augmented)
|
| 4 |
+
- `class_distribution.csv` — raw counts (machine-readable)
|
| 5 |
+
- `sample_grid.png` — one representative image per class (Original Dataset, seed=42)
|
| 6 |
+
|
| 7 |
+
## Class counts
|
| 8 |
+
| Class | Original | Augmented |
|
| 9 |
+
|---|---:|---:|
|
| 10 |
+
| Central Serous Chorioretinopathy [Color Fundus] | 101 | 606 |
|
| 11 |
+
| Diabetic Retinopathy | 1509 | 3444 |
|
| 12 |
+
| Disc Edema | 127 | 762 |
|
| 13 |
+
| Glaucoma | 1349 | 2880 |
|
| 14 |
+
| Healthy | 1024 | 2676 |
|
| 15 |
+
| Macular Scar | 444 | 1937 |
|
| 16 |
+
| Myopia | 500 | 2251 |
|
| 17 |
+
| Pterygium | 17 | 102 |
|
| 18 |
+
| Retinal Detachment | 125 | 750 |
|
| 19 |
+
| Retinitis Pigmentosa | 139 | 834 |
|
| 20 |
+
| **TOTAL** | **5335** | **16242** |
|
dataset/class_distribution.csv
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class,augmented_count,original_count
|
| 2 |
+
Central Serous Chorioretinopathy [Color Fundus],606,101
|
| 3 |
+
Diabetic Retinopathy,3444,1509
|
| 4 |
+
Disc Edema,762,127
|
| 5 |
+
Glaucoma,2880,1349
|
| 6 |
+
Healthy,2676,1024
|
| 7 |
+
Macular Scar,1937,444
|
| 8 |
+
Myopia,2251,500
|
| 9 |
+
Pterygium,102,17
|
| 10 |
+
Retinal Detachment,750,125
|
| 11 |
+
Retinitis Pigmentosa,834,139
|
| 12 |
+
TOTAL,16242,5335
|
dataset/class_distribution.png
ADDED
|
Git LFS Details
|
dataset/sample_grid.png
ADDED
|
Git LFS Details
|