Deep learning models for diabetic retinopathy (DR) grading often generalize poorly to unseen imaging domains, in part because predictions may exploit correlations specific to source datasets rather than retinal pathology. We address this challenge by constructing grading decisions from lesion evidence learned using only image severity labels. Clinical implications of DR grades provide multiple instance constraints that guide competitive learning of lesion and background prototypes at multiple scales. An additive ordinal scoring model then predicts severity exclusively from individual lesion prototype responses, explicitly connecting learned evidence with grading decisions without a global feature classification pathway. To improve the reliability of this evidence, we introduce teacher guided preservation under image degradations and spatial regularization against persistent coordinate preferences. Across six public DR datasets under a leave one domain out protocol, our method attains a mean quadratic weighted kappa of 0.761, outperforming the strongest competing method by 0.036. Localization and prototype removal analyses show that the learned responses align with retinal lesions and contribute to grading decisions. Experiments across five other prototype architectures and under image degradations further demonstrate the generality and robustness of the approach.
Figures & tables
Figure 1: Illustrative motivation for lesion grounded prototype learning on unseen domains. Unconstrained prototype responses can be diffuse, whereas our learned responses are more localized around retinal lesions in these examples. The two most activated prototypes are shown for each method. Pixel annotations are highlighted only for visualization and are never used for training.
Figure 2: Overview of the proposed LWM framework for domain-generalized DR grading.
Held-out Domain
Overall
Method
FGADR
APTOS
DDR
IDRiD
Mess-2
DeepDRiD
Mean κ
Acc
F1
Standard Baselines
ERM (Swin-T [ 22 ] )
.462
.795
.737
.745
.783
.740
.710
.598
.499
ERM (ResNet-50 [ 14 ] )
.463
.831
.726
.765
.776
.693
.709
.604
.473
General DG Methods
MixStyle [ 35 ] ∗
.485
.794
.753
.734
.818
.735
.720
.603
.504
Table 1: Grading performance across six unseen domains under the LODO protocol. Results are averaged over three random seeds. Best and second best results are highlighted in bold and underlined , respectively, including ties at the reported precision. ∗ Reimplemented in our unified pipeline based on the original paper (public code available). † Adapted from official code. ‡ Reimplemented from the original paper without public code. All methods use Swin-T unless otherwise specified.
Variant
κ
Acc
F1
Δκ
Component Ablations
Ours (full)
.761 ± .006
.618
.511
–
w/o severity MIL
.737 ± .009
.579
.495
−.024
w/o competitive assignment
.740 ± .005
.586
.489
−.021
w/ MLP classification head
.715 ± .007
.596
.498
−.046
w/o degradation consistency
.749 ± .004
.607
.505
−.012
Table 2: Ablation study under the six domain LODO protocol. Results are averaged over three random seeds, with standard deviations reported for QWK. Δκ is measured relative to the full model. The global feature classifier is the Swin-T ERM baseline from Table 1 .
Figure 3: Lesion localization on unseen DDR and IDRiD domains. Pixel AUROC (top) and AP (bottom) are reported as mean ± SD (3 seeds). Gray lines indicate chance levels.
Figure 4: Qualitative visualization of lesion prototype evidence on unseen DDR and IDRiD domains. Fine and coarse scale prototypes exhibit spatial responses associated with retinal lesions, contributing 34% and 70% of the additive grading score, respectively. Dashed boxes indicate enlarged regions, while white squares highlight the top- K pooling cells used to compute prototype presence. Lesion annotations are used only for visualization and never during training.
Figure 5: Prototype removal on unseen DDR and IDRiD (mean ± SD, 3 seeds). Removal follows decision contribution, spatial concentration, or random order without retraining. Rankings use retrospective target statistics.
Figure 6: Generality of severity guided lesion learning across five prototype architectures. The plug-in improves lesion alignment and grading QWK; the best localization prototype is selected retrospectively using lesion annotations.
Method
Clean
Blur
Half res.
Noise
ERM
.648
-.053
-.059
-.065
VREx [ 19 ]
.673
-.053
-.054
-.068
SAGM [ 31 ]
.660
-.049
-.039
-.047
MixStyle [ 35 ]
.657
-.020
-.005
-.050
DECO [ 34 ]
.656
-.038
-.019
-.072
AdvBlur [ 17 ]
.646
-.063
-.074
-.050
Table 3: Robustness to image degradations on unseen DDR, IDRiD, and FGADR domains. Clean is QWK on original images; other columns report changes relative to Clean. Results are averaged over three seeds and three domains.
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
Held-out Domain
Overall
Method
Metric
FGADR
APTOS
DDR
IDRiD
Mess-2
DeepDRiD
Mean
Standard Baselines
ERM (Swin-T)
κ
.462
.795
.737
.745
.783
.740
.710
Acc
.467
.579
.679
.578
.683
.603
.598
F1
.376
.455
.521
.536
.597
.507
.499
ERM (ResNet-50)
κ
.463
.831
.726
.765
.776
.693
.709
Appendix
Table S1 : Detailed LODO grading results across six unseen domains (three training seeds). We report quadratic weighted kappa ( κ ), accuracy (Acc), and macro-F1 (F1). Bold and underlined values indicate the highest and second-highest reported values, including ties.
Figure S1 : Complete lesion localization results on unseen DDR, IDRiD, and FGADR domains. Pixel AUROC (top) and average precision (bottom) are reported as mean ± SD across three random seeds. Gray lines indicate chance levels (AUROC of 0.5 and lesion prevalence for AP). Lesion annotations are used only for evaluation.
Dataset
Measure
MA
HE
EX
SE
DDR
Area
12
51
13
217
Coverage
.12
.49
.34
.45
IDRiD
Area
21
143
19
771
Coverage
.15
.51
.31
.60
FGADR
Area
78
138
73
1782
Coverage
.65
.62
.55
.70
Appendix
Table S2 : Annotation granularity across three datasets (150 images each). Area denotes median component area (px 2 ), and coverage denotes the mean annotated fraction within intersected 10×10 pixel cells.
Domain
Method
ρ=0
ρ=3
ρ=6
ρ=12
DDR
Ours
.852
.773
.715
.641
ERM (Grad-CAM)
.840
.837
.834
.826
IDRiD
Ours
.859
.799
.747
.672
ERM (Grad-CAM)
.624
.613
.611
.604
Appendix
Table S3 : Effect of annotation dilation on MA localization AUROC. Ground-truth masks are dilated by ρ pixels while evidence maps remain unchanged.
Method
r
MA
HE
EX
SE
Ours
0
.532
.554
.710
.698
4
.723
.742
.911
.832
ERM (Grad-CAM)
0
.702
.790
.738
.750
4
.695
.789
.742
.730
VREx (Grad-CAM)
0
.721
.842
.796
.765
4
.681
.805
.771
.717
Appendix
Table S4 : FGADR localization AUROC under spatial tolerance r . Evidence is max pooled within an r -cell neighborhood, with nearby negatives excluded. The standard protocol corresponds to r=0 .
Architecture
K
Run
Lesion (%)
Mass
Best
QWK
ProtoPNet
40
B
12.5
.494
.722
.605
A
70.8
.804
.844
.687
PIP-Net
40
B
6.7
.557
.602
.376
A
79.2
.757
.635
.655
Proto-BagNet
50
B
0.0
.501
.535
.041
A
57.3
.582
.638
.472
Appendix
Table S5 : Generality of severity-guided lesion learning across five prototype architectures. B: original architecture retrained in our pipeline; A: with the lesion plug-in. K denotes prototype count. Mass and Best denote lesion localization AUROC from the aggregated evidence map and the retrospectively selected best prototype, respectively. One training seed per configuration.
APTOS
DDR
Method
Clean
Corr.
Rev.
Δκ
Clean
Corr.
Rev.
Δκ
Outside-FOV marker
ERM
.815
.796
.604
−.192±.013
.680
.802
.644
−.157±.005
DECO
.860
.839
.629
−.210±.022
.658
.815
.595
−.220±.028
w/o Pos. Reg.
.868
.869
.868
−.000±.000
.732
.733
.732
−.001±.000
Ours
.851
.851
.851
−.000±.001
.732
.732
.732
−.001±.000
Appendix
Table S6 : Grading performance under synthetic spatial shortcuts. Clean, Corr., and Rev. denote marker-free, training-consistent, and correlation-reversed evaluation, respectively. QWK values are averaged across three seeds, and Δκ=Rev−Corr is reported as mean ± SD. Both LWM variants use LCC-based prototype pooling; ERM and DECO use their respective standard inference procedures.
APTOS
DDR
Method
S≥2
Change (%)
S≥2
Change (%)
Outside-FOV marker
ERM
.226
25.2
.233
24.2
DECO
.226
24.1
.286
29.3
Ours
.001
0.3
.001
0.3
Inside-FOV marker
Appendix
Table S7 : Counterfactual prediction sensitivity ( S≥2 ) and percentage of images with changed predicted grades (Change). All configurations use three training seeds.
Domain
Method
S≥2
TV
ΔE[y]
Change (%)
APTOS
ERM
.211
.223
+.313
23.5
DECO
.248
.261
+.420
26.7
Ours
.180
.294
+.462
52.2
DDR
ERM
.246
.254
+.399
25.4
DECO
.293
.309
+.513
31.2
Ours
.115
.219
+.327
48.2
Appendix
Table S8 : Counterfactual sensitivity to inside-FOV markers. S≥2 measures changes in the probability of moderate-or-worse DR, TV measures total variation between the five-class predictive distributions, ΔE[y] is the signed change in expected grade, and Change denotes the percentage of images with different argmax predictions. Results are averaged over three training seeds.
Method
Mask
Δκ
S≥2
Change (%)
APTOS: Outside-FOV
Ours
Raw
−.245±.044
.191
58.9
Paired
−.000±.001
.001
0.3
LCC
−.000±.001
.001
0.3
w/o Pos.
Raw
−.269±.062
.226
60.4
Paired
−.001±.000
.001
0.4
Appendix
Table S9 : Pooling-mask intervention for outside-FOV markers. Identical checkpoints and marked inputs are used throughout. Paired: unmarked-image mask (diagnostic only); LCC: standard inference. Three seeds; Δκ=Rev−Corr .
Department of Data Science and Artificial Intelligence National University of Computer and Emerging Sciences (FAST-NUCES) Islamabad 44000, Pakistan · Department of Computer Science National University of Computer and Emerging Sciences (FAST-NUCES) Islamabad 44000, Pakistan · Department of Computer Engineering Istinye University Istanbul 34408, Turkey +1