Abstract
Background/Objectives: Diabetic retinopathy (DR) is a major cause of diabetes-related vision loss. Accurate five-class severity grading remains challenging due to class imbalance, the ordered nature of disease severity, and visual similarities between adjacent grades. This study evaluates a multi-architecture ordinal learning framework combining SwinV2, EVA-02, and ConvNeXtV2 with Consistent Rank Logits (CORAL)-based classification. Methods: The models were trained on multiple retinal datasets using Ben Graham preprocessing and APTOS-specific fine-tuning, while four-view test-time augmentation was applied during held-out test inference. Equal-weight soft voting, learned weighting, and stacking were evaluated using out-of-fold (OOF) predictions and nested validation. Performance was assessed through class-specific metrics, ordinal error analysis, and qualitative explanations using Grad-CAM and LIME. Results: The three-model ensemble achieved an OOF Macro-F1 of 0.7419 and Severe-class F1 of 0.5046. Under nested validation, equal-weight soft voting achieved a Macro-F1 of 0.7368 and Severe-class F1 of 0.4880. On the held-out APTOS 2019 test set, the ensemble achieved a Macro-F1 of 0.7263 and Severe-class F1 of 0.4058, compared with 0.7304 and 0.4286 for EVA-02, respectively. Paired bootstrap comparisons showed no statistically significant differences in these test metrics. Error analysis showed that 83.1% of incorrect OOF predictions differed by one severity grade, while 98.5% differed by no more than two grades. The CORAL–Softmax comparison was limited to EVA-02 using a single random seed. Conclusions: The held-out test contained only 39 Severe images, limiting the precision of class-specific estimates. Overall, the findings highlight the importance of rigorous ensemble validation and class-specific evaluation for DR grading.
1. Introduction
Diabetic retinopathy (DR) is a major complication of diabetes and a leading cause of vision loss. Early detection and accurate severity grading are central to preventing avoidable visual impairment [1,2]. Clinical DR grading commonly follows five severity levels: No DR, Mild, Moderate, Severe non-proliferative DR, and Proliferative DR (PDR) [1]. Deep learning applied to retinal fundus images has shown strong results for both DR detection and grading [3,4].
Despite this progress, five-class DR grading remains challenging because disease severity must be distinguished across multiple ordered stages, while retinal datasets often contain substantially different numbers of images across classes [3]. Recent reviews note that advanced DR stages are commonly underrepresented relative to No DR and Mild cases, which can affect the recognition of clinically important minority classes [5]. In addition, the five DR categories are ordered, but standard multiclass classification ignores the ordering of the grades. Ordinal regression provides an alternative by modeling the relationships between ordered classes through cumulative binary decisions [6].
Recent DR studies have increasingly explored both convolutional neural networks and vision-transformer-based models for fundus-image classification [5,7]. These architectures can learn different representations of retinal images, providing a basis for comparing or combining diverse models. Ensemble approaches have also been investigated for DR analysis, with studies reporting benefits from combining predictions from multiple deep-learning models [8]. However, ensemble performance gains depend on the selection of several design choices, which makes systematic validation necessary [8].
A further challenge is variation between retinal datasets. Differences in imaging devices, acquisition conditions, and other domain characteristics can produce distribution shifts that reduce DR grading performance across datasets [9]. Training on multiple sources exposes models to broader variation. Adaptation to the target domain, such as source-free active domain adaptation, has been studied to address domain differences [10]. These issues motivate evaluation strategies that consider class imbalance, ordinal disease severity, architectural diversity, and minority-class recognition together.
In this work, we present a multi-architecture ordinal framework for five-class DR grading that combines SwinV2 [11], EVA-02 [12], and ConvNeXtV2 [13] backbones with a CORAL-based ordinal classification formulation. The models are trained on multiple retinal datasets and adapted to the APTOS 2019 [14] dataset. We compare equal-weight soft voting, learned weighting, and stacking using out-of-fold (OOF) predictions and nested validation. We further analyze Severe-class results, ordinal error patterns, and model disagreement, and we use Grad-CAM and LIME to qualitatively inspect the image regions behind the model predictions.
This study evaluates established components rather than proposing a new architecture. Its contribution lies in the comparative evaluation of three backbones under a shared ordinal learning framework, the controlled comparison of CORAL and softmax classification using EVA-02, and the assessment of ensemble strategies through OOF predictions and nested validation. The evaluation further includes paired statistical comparisons, Severe-class error analysis, model disagreement, and qualitative explanations using Grad-CAM and LIME.
1.1. Related Work
Deep learning (DL) has become the dominant approach for automated DR screening and multiclass grading from retinal fundus images. Early studies rely on CNNs to learn discriminative retinal features, while more recent studies have explored transformer-based, hybrid, and ensemble architectures. These developments have focused on improving classification performance, handling class imbalance, modeling disease severity, and increasing the efficiency and interpretability of automated DR grading.
1.1.1. CNN-Based Approaches
Several CNN-based approaches have been investigated for multiclass DR grading using retinal fundus images. Mardianta et al. [15] combined Contrast Limited Adaptive Histogram Equalization (CLAHE) preprocessing and SMOTE oversampling with an Xception backbone and reported 95.26% accuracy. Kasim [16] employed MobileNet for feature extraction followed by mRMR-based feature selection and a bagging classifier, reporting approximately 89% accuracy. Other studies have addressed class imbalance through extensive augmentation strategies [17]. Farag et al. [18] developed a DenseNet169-based framework with a Convolutional Block Attention Module (CBAM) and class-weighted learning, reporting 82% accuracy, a Macro-F1 score of 0.68, and a quadratic weighted kappa (QWK) of 0.888 for five-class grading on APTOS 2019. These studies demonstrate the effectiveness of CNN-based feature learning but also show continued reliance on preprocessing, augmentation, and class-balancing strategies to address the challenges of multiclass DR grading.
1.1.2. Transformer-Based and Attention-Enhanced Approaches
More recent studies have explored Transformer architectures to capture broader contextual information from retinal fundus images. Yu et al. [19] combined a Swin Transformer backbone with a CLIP-based semantic-prior module and dual ordinal and classification heads, achieving a QWK of 0.937 on APTOS 2019. ElAdel et al. [20] employed a compact convolutional Transformer for five-class grading using a combined EyePACS–APTOS dataset and reported an accuracy of 97% and an F1-score of 0.98 for the Severe class. Meanwhile, Yang et al. [21] introduced a multiple-instance-learning Transformer that processes high-resolution fundus images as image patches using ViT-Small and aggregates their representations through a Global Instance Computing Block, reporting 73.68% recall for the Severe class. Rizvana et al. [22] developed an enhanced-attention ViT architecture and reported an average F1-score of 84.99% across five cross-validation folds.
Recent studies have introduced different mechanisms into standard transformer architectures to improve feature representation and computational efficiency. Researchers have investigated frequency–spatial feature fusion, multi-branch fine-grained learning, and model pruning and quantization to improve discriminative representations or reduce computational requirements [23,24,25]. Palaniappan et al. [26] proposed Swin-DRNet, incorporating class-aware attention, cross-attention fusion, and focal-loss optimization, and reported 98.73% accuracy and an F1-score of 100% for the Severe class on APTOS 2019. Boulaabi et al. [27] also employed a Swin Transformer with shifted-window attention for multiclass DR grading, achieving 89.65% accuracy and a Severe-class F1 of 0.74. Collectively, these studies indicate a shift toward architectures that explicitly enhance global contextual modeling, class-specific representation, or computational efficiency.
1.1.3. Hybrid and Ensemble Approaches
Hybrid and ensemble approaches have further explored the complementary properties of CNNs and Transformers. Such approaches can combine local feature extraction with global contextual modeling for DR grading. Maaod et al. [28] evaluated more than twenty pretrained CNN and Transformer architectures, then constructed hybrid models and prediction ensemble using soft voting, achieving 93.10% accuracy and an F1-score of 93.07% on APTOS 2019. Ataş et al. [29] proposed an adaptive gated fusion framework that integrates EfficientNet-B0 and Swin Transformer features, reporting 84.31% accuracy and a QWK of 0.905 on APTOS 2019. Touati et al. [30] proposed a compact convolutional Transformer based on convolutional tokenization and Transformer-based global feature learning, reporting an average F1-score of 0.973 and a Severe-class F1 of 0.98 in its APTOS-based evaluation.
Other hybrid approaches have focused on enhancing feature representation through attention mechanisms and multi-scale feature extraction. Wang et al. and Gou et al. [31,32] developed related MobileViT-based architectures for five-class DR grading on APTOS 2019. Both approaches integrated multi-scale feature extraction, attention mechanisms, and Transformer-based global modeling, reporting F1-scores of 88.4% and 89.6%, respectively, with the latter also achieving a QWK of 0.931. Although these studies reported promising classification performance, further evaluation is needed to determine whether combining different architectures and using more complex fusion strategies provides consistent benefits under rigorous validation protocols.
1.1.4. Explainable Artificial Intelligence (XAI) for DR Grading
Recent studies have incorporated XAI techniques into DR grading to provide visual or feature-level information about model predictions. Ghadai et al. [33] applied Grad-CAM to an EfficientNet-B1 framework to examine classification errors, including confusion between adjacent disease stages. Similarly, Sekar et al. and Yi et al. [34,35] employed Grad-CAM to visualize influential retinal regions in hybrid architectures. Sekar et al. also examined the clinical usefulness of the generated explanations through evaluation by three ophthalmologists. Zhang et al. [36], compared explanations from CNN, Transformer, and hybrid architectures using Grad-CAM and Attention-Rollout, while Ikram et al. [37] combined Grad-CAM and LIME to interpret the predictions from a hybrid ResNet50–Vision Transformer model. Additionally, Al Shafi et al. [38] used SHAP to visualize image regions contributing to MobileViTv2 predictions, including a representative Severe DR case. These studies demonstrate the growing role of XAI in understanding DR grading predictions. However, there is a need to systematically examine how different architectures behave on both correct and incorrect predictions. Furthermore, the relationship between model disagreement, classification errors, and explanations for challenging severity grades is still less explored.
1.1.5. Research Gaps and Motivation
Despite substantial progress in automated DR grading, several methodological gaps need to be addressed. First, many studies emphasize overall accuracy or aggregate F1 scores, with less consistent attention to the recognition of underrepresented severity grades. Second, although ordinal learning has been investigated, conventional multiclass classification remains common and does not explicitly account for the ordered nature of DR severity. Third, ensemble methods have demonstrated the potential of combining complementary architectures, but the relative benefits of simple and complex fusion strategies require further evaluation under rigorous validation protocols. Finally, although explainable AI techniques have been applied to DR models, fewer studies have examined model behavior across heterogeneous architectures while considering both correct and incorrect predictions, particularly for difficult minority classes. These gaps motivate an evaluation framework that considers class-specific performance, the ordinal structure of DR severity, architectural diversity, robust ensemble validation, and systematic error and explainability analyses.
2. Materials and Methods
In this section, we present the proposed diabetic retinopathy grading framework, including dataset descriptions, preprocessing procedures, the multi-architecture ordinal framework, and the training strategy. It also describes the ensemble construction and evaluation protocol. Finally, error analysis and explainability methods are employed to investigate model misclassifications and identify the image regions that influence model predictions. An overview of our framework is provided in Figure 1.
Figure 1.
Overview of the five-class diabetic retinopathy grading framework, covering data preparation, ordinal modelling, ensemble inference, performance evaluation, error, and explainability analysis.
2.1. Dataset and Preprocessing
Three publicly available retinal fundus image datasets were used in this study: APTOS 2019 [14], EyePACS [39], and Messidor-2 [40]. Representative fundus images from the three datasets across the five DR grades are shown in Figure 2. These datasets were combined to form a multi-source pool of 15,430 retinal images, each with one image-level DR grade, to increase the representation of less frequent diabetic retinopathy grades, as summarized in Table 1. To mitigate the dominance of the larger EyePACS dataset, a maximum of 3000 images per class was retained using a fixed random seed of 42, yielding 10,024 EyePACS images in the final pool.
Figure 2.
Representative retinal fundus images from the APTOS 2019, Messidor-2, and EyePACS datasets across the five diabetic retinopathy severity grades (0–4).
Table 1.
The class distribution of DR grades across the three retinal fundus datasets used in this study. Counts are images, with one DR grade per image. The EyePACS counts are those retained after the cap of 3000 images per class (Section 2.1).
All retinal images underwent a unified preprocessing pipeline based on the Ben Graham approach before model training [41]. First, the dark background surrounding the fundus was removed by cropping to the bounding box of pixels with a grayscale value above 7. The resulting images were then padded to a square aspect ratio to prevent geometric distortion during scaling and resized to pixels. To reduce illumination variations and camera-related differences across the three datasets, local contrast enhancement was subsequently applied using unsharp masking on the resized 8-bit RGB images, separately for each color channel, as follows:
where denotes a Gaussian kernel with pixels and * represents convolution. No circular retinal mask or CLAHE was applied. The processed images were cached to improve training efficiency. The resolution was selected to balance computational efficiency with the preservation of retinal details. To accommodate model-specific architectural constraints, ConvNeXtV2 and SwinV2 were trained using inputs, whereas EVA-02 inputs were resized to pixels to maintain compatibility with its patch configuration [12].
To assess data integrity, exact and near-duplicate images were identified using MD5 hashing, perceptual hashing (pHash; Hamming distance ), and structural similarity (SSIM ) on 128-pixel grayscale images. The analysis identified 152 near-duplicate pairs, including 138 exact duplicates, with no detected pairs involving EyePACS. Among the APTOS images, 54 held-out test images had near-duplicates in the training data, while 112 OOF images had near-duplicates in other cross-validation folds. The potential impact of these overlapping images on held-out test performance was further examined through a sensitivity analysis in which the 54 identified test images were excluded from evaluation.
Patient-level independence could not be verified for APTOS and Messidor-2 because suitable patient identifiers were unavailable. In the separate multi-source evaluation, 800 of the 2005 held-out EyePACS images had fellow-eye images in the training set. These data-integrity issues are acknowledged as limitations of the study.
The dataset partitions and experimental protocols used in the subsequent experiments are summarized in Table 2.
Table 2.
Summary of experimental protocols, dataset partitions, and evaluation objectives.
2.2. The Proposed Framework and Training Strategy
The proposed framework integrates three complementary deep learning architectures, SwinV2, EVA-02, and ConvNeXtV2, for five-class diabetic retinopathy grading. The framework employs three-fold stratified cross-validation, OOF predictions, and nested validation. An additional APTOS-specific fine-tuning phase was incorporated to improve adaptation to the target dataset.
2.2.1. Model Architectures and Ordinal Classification
Each model was initialized using pretrained weights and adapted to the ordinal nature of the grading task using a CORAL-based classification head [6,19]. Unlike conventional multiclass classification, which treats grades as independent categories, ordinal classification accounts for their inherent ordering. Accordingly, the CORAL head generates four ordinal outputs representing the cumulative severity thresholds between the five DR grades, from No DR to proliferative diabetic retinopathy.
2.2.2. Training Strategy and Optimization
To mitigate the class imbalance in the training dataset, weighted random sampling was employed using inverse-square-root class-frequency weighting with a sampling power of 0.5. This strategy increases the sampling probability of underrepresented classes while limiting excessive oversampling. Furthermore, a hybrid loss function combining the CORAL ordinal loss [6] with Focal Loss [42] was adopted. It addresses class imbalance and emphasizes hard-to-classify and underrepresented examples. The focal-loss component was assigned a weight of 0.2, with a focusing parameter of .
The final training objective combines the CORAL ordinal loss with a focal-loss term derived from the reconstructed class probabilities:
where the CORAL loss is defined as
with
and the focal-loss component is computed as
where is the predicted probability assigned to the true class and is the focusing parameter. The class probabilities are reconstructed from the cumulative ordinal probabilities as
In this study, , corresponding to the five diabetic retinopathy grades. The hyperparameters were set to and .
All models were optimized using AdamW with a weight decay of . To account for the different optimization requirements of the pretrained backbones and the newly initialized CORAL heads, separate learning rates were assigned to the two parameter groups, with the CORAL head learning rate set to ten times that of the backbone. Specifically, the backbone learning rates were set to for SwinV2, and for both EVA-02 and ConvNeXtV2. A cosine learning-rate schedule with two warm-up epochs was employed together with gradient clipping to improve training stability.
Training was conducted in two sequential phases. In the first phase, each model was trained on the combined multi-source dataset, with early stopping based on validation Macro-F1 to select the best-performing checkpoint. In the second phase, the selected checkpoints underwent an additional three epochs of fine-tuning using APTOS training images exclusively to adapt the models to the target dataset. During fine-tuning, mixup augmentation was disabled, and the backbone learning rate was reduced to 10% of its initial value. A fine-tuned checkpoint was retained only if it achieved a higher validation Macro-F1 than its predecessor. This two-phase strategy was applied independently to all three architectures, enabling them to leverage the rich representation of the multi-source distribution before adapting to the specific target dataset.
The architecture-specific training configurations are summarized in Table 3. The CORAL head learning rate was set to 10 times the backbone learning rate, while the fine-tuning learning rate was reduced by a factor of 0.1. The main experiment comprised three architectures trained across three folds and two sequential phases, resulting in 18 training-phase runs and nine final fold-specific models.
Table 3.
Training configurations of the three architectures.
2.3. Ensemble and Evaluation Protocol
A structured evaluation protocol was adopted to assess the individual models and their ensemble while limiting optimistic performance estimates [43]. For each architecture, three-fold stratified cross-validation was performed on the APTOS 2019 [14] cross-validation pool comprising 2929 images. EyePACS and Messidor-2 were not partitioned into cross-validation folds and remained available as auxiliary training data in each round.
In each round, the APTOS cross-validation pool was divided into three stratified folds. Two folds were combined with the auxiliary training data from EyePACS and Messidor-2 to train the model, while the remaining APTOS fold was used for validation. This procedure was repeated three times, with each APTOS fold serving as the validation fold once. Consequently, each APTOS image received one out-of-fold (OOF) prediction from a fold-specific model whose gradient-based training did not include that image. However, the validation folds were used for early stopping and checkpoint selection, which may introduce some model-selection optimism into the OOF performance estimates. The OOF predictions were subsequently aggregated for individual-model comparison, threshold calibration, and ensemble analysis.
The independent APTOS test set, comprising 733 images, was kept separate from the cross-validation procedure and reserved for final evaluation. It was not used for model training, checkpoint selection, threshold optimization, or ensemble development. The separation between the APTOS cross-validation pool and the held-out test set was verified using image identifiers.
Four CORAL decision thresholds were optimized on the OOF predictions to maximize Macro-F1. Optimization used the Nelder–Mead algorithm with eight initializations, with each threshold constrained to the range [0.15, 0.85]. For the held-out evaluation, the thresholds were fitted once using all 2929 OOF predictions and subsequently kept fixed when evaluating the independent APTOS test set. During nested validation of the ensemble strategies, the thresholds were re-fitted using only the training portion of each outer fold. Since threshold fitting is a data-dependent selection step, OOF performance estimates obtained using thresholds optimized on the same OOF predictions may be optimistic. A sensitivity analysis was also performed to compare fixed thresholds of 0.5 with thresholds optimized for Macro-F1 and quadratic weighted kappa (QWK).
A near-duplicate sensitivity analysis was performed on the held-out APTOS test set by excluding 54 images similar to training data (733 to 679 images). Performance was evaluated using the original predictions and fixed OOF-optimized CORAL thresholds. Changes in Accuracy, Macro-F1, Severe-class F1, and QWK were calculated, with 95% confidence intervals for the differences estimated using 2000 paired bootstrap resamples.
On the held-out APTOS test set, four-view test-time augmentation (TTA) was applied using the original image, horizontal flip, vertical flip, and combined horizontal–vertical flip. The cumulative CORAL probabilities from the four views were averaged with equal weights, followed by equal-weight averaging across the three fold-specific checkpoints of each architecture. In contrast, OOF predictions were generated without TTA using the corresponding fold-specific checkpoint. Consequently, the OOF and held-out test predictions were obtained under different inference configurations, which should be considered when interpreting differences between their performance estimates.
The outputs of SwinV2, EVA-02, and ConvNeXtV2 were combined using soft voting [28]. Equal-weight averaging of the cumulative CORAL probabilities was adopted as the primary ensemble strategy, while alternative weighting schemes and stacking approaches were evaluated using OOF predictions. To assess whether learned ensemble configurations generalized beyond the data used for their selection, these strategies were further evaluated using nested cross-validation [44].
Nested validation was performed on the APTOS OOF predictions () using five stratified outer folds with a fixed random seed of 42. Within each outer fold, ensemble weights were selected through a grid search with a step size of 0.05, or a stacking meta-learner was trained on the four outer-training partitions. The four CORAL decision thresholds were subsequently optimized using the training portion of that outer fold. For equal-weight soft voting, only the thresholds were fitted, whereas the ordinal stacking approach involved fitting both the meta-learner and its decision thresholds. Each resulting configuration was evaluated once on the corresponding held-out outer fold. Predictions from the five outer folds were pooled to calculate Macro-F1 and Severe-class F1, together with bootstrap confidence intervals.
The base models were not retrained within the nested outer folds. Moreover, the original validation folds had been used for early stopping and checkpoint selection. Thus, nested validation assessed the ensemble combination and threshold-selection stages rather than the complete training pipeline. It did not eliminate all potential sources of model-selection optimism.
Before ensemble aggregation, the ordering of OOF samples was verified across the three architectures to ensure correct alignment between model predictions and ground-truth labels.
Statistical uncertainty was quantified using nonparametric percentile bootstrap resampling at the image level [45]. For the nested ensemble evaluation, 95% confidence intervals (CIs) were estimated using 1000 bootstrap resamples of the pooled outer-fold predictions (n = 2929; seed = 42). Images were sampled with replacement, and the 95% CIs were obtained from the 2.5th and 97.5th percentiles of the bootstrap metric distributions. The primary metrics included Macro-F1 and Severe-class F1, with additional evaluation using accuracy and QWK.
The primary bootstrap analysis treated model predictions, ensemble weights, and decision thresholds as fixed. Statistical comparisons between systems were conducted using paired bootstrap resampling, in which identical image indices were used for both systems within each iteration. Confidence intervals for performance differences were obtained from the resulting paired bootstrap distributions. Exact McNemar tests were additionally applied to compare per-image classification correctness. These analyses quantified image-level sampling uncertainty but did not account for variability arising from retraining the base models.
To assess uncertainty associated with threshold selection, an additional threshold-refit bootstrap analysis was conducted using 500 resamples. In each iteration, OOF predictions were resampled with replacement, and the four CORAL thresholds were re-optimized by maximizing Macro-F1 using the Nelder–Mead algorithm with a single initialization. The resulting thresholds were then applied to an independently resampled held-out test set. The base-model weights remained fixed throughout this procedure. Therefore, this analysis incorporated uncertainty associated with threshold selection and test-image sampling but did not capture variability arising from model retraining.
2.4. Ablation Study
An ablation study was conducted to investigate the effects of multi-source training, APTOS-specific fine-tuning, and the CORAL-based ordinal classification approach. Each component was evaluated through separate experimental comparisons to assess its impact on model performance.
2.4.1. Effect of Multi-Source Training
To investigate the effect of multi-source training, EVA-02 was trained under two settings: using APTOS training data alone and using the combined APTOS 2019, EyePACS, and Messidor-2 datasets. Both settings incorporated the same APTOS-specific fine-tuning stage, with all other training and evaluation procedures held constant. This comparison was designed to isolate the contribution of multi-source training to the performance of the EVA-02 configuration.
2.4.2. Effect of APTOS-Specific Fine-Tuning
To evaluate the contribution of APTOS-specific fine-tuning, an ensemble model of SwinV2 and EVA-02 was evaluated before and after the fine-tuning stage under the same evaluation protocol. The comparison was designed to quantify the effect of target-specific fine-tuning on the model performance.
2.4.3. Effect of Ordinal Classification and Focal Loss
To evaluate the effect of ordinal classification and focal loss, EVA-02 was compared under four configurations: Softmax with Cross-Entropy, Softmax with Focal Loss, CORAL only, and CORAL with Focal Loss. All configurations followed the same data splits and training protocol. Performance was evaluated using APTOS out-of-fold predictions and the independent test set, with statistical comparisons to assess the contribution of each component.
2.5. Multi-Source Generalization Evaluation
To evaluate multi-source generalization and the effect of APTOS-specific fine-tuning, APTOS 2019, EyePACS, and Messidor-2 were partitioned using stratification by DR grade and data source (seed = 42). The original 80/10/10 split was consolidated into 80% training and 20% held-out data, as summarized in Table 2.
SwinV2, EVA-02, and ConvNeXtV2 were trained on the combined training subsets. Each model was evaluated before and after APTOS-specific fine-tuning, using only APTOS training images during the fine-tuning phase.
The final soft-voting ensemble was evaluated under both conditions on each dataset’s held-out subset and the combined multi-source test set. Held-out images were excluded from training, model selection, and threshold optimization. Early stopping and threshold optimization used only the APTOS cross-validation folds within the training pool.
2.6. Error Analysis
Error analysis was conducted using the OOF predictions generated from the APTOS training pool. The confusion matrix and Severe-class error analysis were also performed on the independent held-out APTOS test set using thresholds optimized on OOF predictions.
A five-class confusion matrix was first examined to identify the predominant misclassification patterns across DR grades. Given the ordinal nature of DR grading, the severity of each error was also quantified using the absolute distance between the predicted and ground-truth grades:
where denotes the ground-truth DR grade, represents the predicted grade, and denotes the ordinal error distance for image i. This measure distinguishes adjacent-grade misclassifications from errors involving larger differences in disease severity.
The predictions of SwinV2, EVA-02, and ConvNeXtV2 were compared with the ensemble prediction for every image. Images with a correct ensemble prediction were labeled ensemble-correct. Each ensemble misclassification was assigned to one of three categories. In unanimous-wrong errors, all three models produced the same incorrect grade. In all-wrong disagreement errors, all three models were incorrect but predicted different grades. In split-decision errors, at least one model predicted the correct grade. Errors involving Severe DR were analyzed separately to characterize both under- and over-classification patterns in this clinically important minority class. Finally, a per-image error table was generated, containing the ground-truth label, the ensemble prediction, the ordinal error distance, and the individual model predictions. This table serves as the basis for the subsequent explainability analysis.
2.7. Explainability Analysis
Explainability analysis was conducted on selected true-Severe DR cases identified through the OOF error analysis. Three representative cases were presented, covering all-correct (all three models predicted the correct grade), split-decision, and unanimous-wrong cases.
Grad-CAM [46] and LIME [47] were employed as complementary explanation methods to qualitatively examine the retinal regions influencing model predictions. Both methods explained the same target, defined as the probability of the class predicted by each model. The cumulative CORAL probabilities were converted into five class-specific probabilities as follows:
The predicted-class probability was used as the common explanation target for Grad-CAM and LIME. For transformer-based models, the final backbone features were reshaped into spatial feature maps for Grad-CAM computation. LIME was applied using quickshift superpixel segmentation with 500 perturbation samples per image. The combined use of Grad-CAM and LIME in DR grading has also been reported in previous work [37].
For each selected OOF image, the checkpoint corresponding to its validation fold was restored to generate the explanations. The restored model predictions were checked against the stored OOF probabilities to verify consistency. Cases were selected using a fixed random seed of 42, with one representative image selected from each of the three categories: all-correct, split-decision, and unanimous-wrong. The all-wrong disagreement category was excluded from the qualitative examples. Each explanation panel reports the model name, true grade, predicted grade, and probability assigned to the predicted class. The explanations were interpreted qualitatively, without quantitative lesion-localization validation or claims of clinical validity.
During the implementation of the explainability analysis, ChatGPT (OpenAI, GPT-5) was used to assist in interpreting programming error messages and troubleshooting issues encountered in the Grad-CAM and LIME code. The authors remained responsible for reviewing the code and verifying the resulting outputs.
3. Results
3.1. Classification Performance
This section evaluates the performance of the individual architectures and their ensemble combinations using APTOS OOF predictions and the independent held-out test set. The purpose of this analysis is to determine whether combining multiple architectures provides an advantage over using a single model. The performance of the individual models and their ensemble combinations is summarized in Table 4. Among the individual architectures, EVA-02 achieved the highest overall OOF performance, with an accuracy of 85.35%, a Macro-F1 score of 0.7310, and a QWK of 0.9296. ConvNeXtV2 and SwinV2 achieved Macro-F1 scores of 0.7236 and 0.7189, respectively. For Severe-class classification, ConvNeXtV2 and EVA-02 achieved comparable F1-scores of 0.4706 and 0.4699, respectively, while SwinV2 obtained 0.4474. Among the evaluated ensemble configurations, the three-model ensemble achieved the highest OOF Macro-F1 of 0.7419 and Severe-class F1 of 0.5046, indicating a numerical improvement over the individual models.
Table 4.
The classification performance of individual models and equal-weight ensemble combinations based on APTOS out-of-fold (OOF) predictions.
Table 5 presents held-out APTOS test performance using OOF-optimized CORAL thresholds. EVA-02 achieved the highest Macro-F1 (0.7304), while the SwinV2 + EVA-02 ensemble achieved the highest Severe-class F1 (0.4324). The three-model ensemble achieved a Macro-F1 of 0.7263 and Severe-class F1 of 0.4058, both lower than those of EVA-02. A paired bootstrap comparison between the three-model ensemble and EVA-02 showed no statistically significant difference in test Macro-F1 (difference: −0.0041; 95% CI: [−0.0295, 0.0219]) or Severe-class F1 (difference: −0.0228; 95% CI: [−0.1105, 0.0643]). Thus, the numerical OOF advantage of the three-model ensemble was not confirmed on the independent test set.
Table 5.
Classification performance of individual models and equal-weight ensemble combinations on the held-out APTOS test set (), using OOF-optimized CORAL thresholds. The 95% confidence intervals (CIs) were estimated using 2000 bootstrap resamples.
To evaluate the influence of near-duplicate images on the reported test performance, an additional sensitivity analysis was conducted after excluding 54 test images that were highly similar to training images. As shown in Table 6, the three-model ensemble’s Macro-F1 decreased from 0.7263 to 0.7191 (; 95% CI: ), while Severe-class F1 decreased from 0.4058 to 0.3871 (; 95% CI: ). Both confidence intervals included zero. EVA-02 achieved the highest Macro-F1 (0.7325) and Severe-class F1 (0.4444) among the four systems evaluated on the filtered subset.
Table 6.
Sensitivity analysis of held-out APTOS test performance before and after excluding 54 near-duplicate images.
To examine the sensitivity of the results to CORAL threshold selection, Table 7 compares fixed thresholds of 0.5 with thresholds optimized for Macro-F1 and QWK using OOF predictions. Although Macro-F1 optimization improved OOF Macro-F1 across all seven systems, test Macro-F1 decreased for six systems compared with fixed thresholds. For the three-model ensemble, test Macro-F1 decreased from 0.7292 to 0.7263, while Severe-class F1 decreased from 0.4416 to 0.4058. These findings indicate that improvements observed during OOF threshold calibration did not consistently transfer to the independent test set.
Table 7.
Threshold-sensitivity analysis of the seven systems on APTOS OOF predictions () and the independent held-out test set (). Thresholds optimized for Macro-F1 or quadratic weighted kappa (QWK) were fitted using OOF predictions only; the fixed strategy uses thresholds of 0.5.
3.2. Ensemble Strategy Validation Performance
This section examines how the outputs of the three architectures should be combined. The goal is to determine if a more complex ensemble strategy provides an advantage over the simple equal-weight soft voting. Three stacking approaches—ordinal logistic regression (Ordinal LR), multinomial logistic regression (Multinomial LR), and histogram-based gradient boosting (HistGBM)—were evaluated using the outputs of the three architectures as input features. Their performance was assessed using nested five-fold cross-validation on the OOF predictions, as presented in Table 8. The equal-weight soft-voting ensemble achieved a Macro-F1 of 0.7368 and a Severe-class F1 of 0.4880. Among the stacking methods, multinomial logistic regression achieved the highest Macro-F1 of 0.7276, whereas ordinal logistic regression obtained the highest Severe-class F1 of 0.4494. However, none of the stacking approaches surpassed the equal-weight soft voting on either metric, supporting the selection of equal-weight soft voting as the final ensemble strategy.
Table 8.
Comparison of equal-weight soft voting and stacking approaches using nested five-fold cross-validation on APTOS OOF predictions (). The 95% confidence intervals were estimated using 1000 image-level bootstrap resamples of the pooled outer-fold predictions.
3.3. Equal Versus Optimized Ensemble Weights
This analysis investigates whether assigning different weights to the three architectures improves ensemble performance compared with assigning equal weights. Although weight optimization on the complete OOF predictions suggested a possible improvement, this apparent advantage was not maintained under the nested weight-validation analysis. In this analysis, the equal-weight soft-voting ensemble achieved a Macro-F1 of 0.7368 (95% CI: 0.7150–0.7584) and a Severe-class F1 of 0.4880 (95% CI: 0.4191–0.5546), whereas the optimized-weight ensemble achieved a lower Macro-F1 of 0.7322 (95% CI: 0.7092–0.7543) and a Severe-class F1 of 0.4815 (95% CI: 0.4051–0.5471). The resulting change in Macro-F1 was , and the confidence intervals of the two ensembles overlapped. Because these intervals were computed separately, their overlap does not constitute a paired statistical test. Therefore, the comparison provided no evidence that optimized weights were superior to equal weights, but it does not establish equivalent performance.
3.4. Ablation Study
3.4.1. Effect of Multi-Source Training
As shown in Table 9, multi-source training produced different effects across evaluation metrics. Using the optimized CORAL thresholds, the EVA-02 model achieved a Macro-F1 of 0.7310 when trained on APTOS, EyePACS, and Messidor-2 datasets, compared with 0.7275 when trained on APTOS alone. However, the Severe-class F1 decreased from 0.4821 to 0.4699. These differences were not statistically tested and may be affected by run-to-run variability and differences in class distributions and image characteristics across datasets. Therefore, no definitive conclusion can be drawn regarding the effect of multi-source training on Severe-class recognition.
Table 9.
Effect of multi-source training on the EVA-02 model using optimized CORAL thresholds, evaluated on APTOS OOF predictions.
3.4.2. Effect of APTOS-Specific Fine-Tuning
As shown in Table 10, applying APTOS-specific fine-tuning to the SwinV2 + EVA-02 ensemble improved the nested Macro-F1 from 0.7205 to 0.7224 and the Severe-class F1 increased from 0.4300 to 0.4785. These results suggest that, for this two-model ensemble, APTOS-specific fine-tuning had a limited effect on overall performance but was associated with improved recognition of Severe DR.
Table 10.
Effect of APTOS-specific fine-tuning on the SwinV2 + EVA-02 ensemble.
3.4.3. Effect of Ordinal Classification and Focal Loss
As shown in Table 11, CORAL without focal loss achieved the highest Macro-F1 (0.7404), the joint-highest Severe-class F1 (0.4478), and the lowest ordinal mean absolute error (Ordinal MAE) of 0.1583 on the APTOS held-out test set. In contrast, CORAL with focal loss achieved the highest QWK (0.9299). However, paired bootstrap comparisons showed no statistically significant differences in Macro-F1 or Severe-class F1 between CORAL with focal loss and the other configurations. These findings indicate that performance varied across evaluation metrics, without demonstrating a consistent advantage from adding focal loss under the evaluated EVA-02 configuration. Confusion matrix analysis further showed that Severe cases were frequently misclassified as Moderate across all four configurations, with no improvement in Severe-class recall when focal loss was added to CORAL.
Table 11.
Comparison of CORAL and Softmax classification with and without Focal Loss using EVA-02 on APTOS OOF and held-out test sets.
3.5. Multi-Source Test Evaluation
To assess the effect of APTOS-specific fine-tuning on multi-source dataset performance, the final ensemble was evaluated with and without the fine-tuning phase on the held-out test subsets of APTOS 2019, EyePACS, and Messidor-2, as well as on the combined multi-source test set. As shown in Table 12, fine-tuning slightly improved macro-F1 and Severe-class F1 on APTOS, from 0.7262 to 0.7305 and from 0.4194 to 0.4308, respectively. On EyePACS, both metrics decreased slightly after fine-tuning, whereas Messidor-2 showed improvements in macro-F1 from 0.7517 to 0.7855 and in Severe-class F1 from 0.8000 to 0.8276. On the combined multi-source test set, fine-tuning increased macro-F1 from 0.6776 to 0.6818, while Severe-class F1 remained nearly unchanged (0.5330 vs. 0.5315).
Table 12.
Effect of APTOS-specific fine-tuning using the final equal-weight soft-voting ensemble model evaluated on the three test subsets.
Overall, APTOS-specific fine-tuning was associated with improved performance on APTOS and Messidor-2, while EyePACS showed a slight decline. A domain-shift analysis revealed measurable differences between the datasets, with a source-classification accuracy of 0.8824 and greater color-distribution differences involving EyePACS. However, these findings do not establish a causal relationship between domain shift and the observed performance changes.
A fellow-eye sensitivity analysis showed that excluding 800 overlapping EyePACS images reduced the ensemble macro-F1 from 0.6467 to 0.6104 and Severe-class F1 from 0.5254 to 0.4040. The corresponding bootstrap differences were 0.0362 (95% CI: 0.0073–0.0701) and 0.1213 (95% CI: 0.0278–0.2305), respectively. However, these differences cannot be attributed solely to patient overlap because the exclusion also changed the class distribution. Therefore, the multi-source findings should be interpreted cautiously.
3.6. Error and Minority-Class Analysis
The confusion matrix of the final equal-weight ensemble on the OOF validation set is shown in Figure 3a, with absolute counts and row-normalized percentages. The ensemble achieved high recognition of the No DR class and comparatively high recall for the Moderate and Proliferative classes, while misclassifications were concentrated primarily between adjacent severity grades. Across the 2929 OOF samples, 413 predictions were incorrect, corresponding to an overall error rate of 14.1%. Of these misclassified samples, 343 (83.1%) differed from the true grade by one severity level, 64 (15.5%) differed by two levels, and only 6 (1.5%) differed by three levels. Thus, 98.5% of the misclassifications were within two severity levels of the true label, indicating that most errors were ordinally close to the correct DR stage.
Figure 3.
Confusion matrices of the final equal-weight soft-voting ensemble on (a) APTOS out-of-fold (OOF) predictions () and (b) the independent held-out APTOS test set (). Each cell displays the absolute number of images and the corresponding row-normalized percentage.
On the held-out APTOS test set, the ensemble correctly classified 14 of the 39 Severe images (35.9%), as shown in Figure 3b. Fourteen Severe images were under-graded as Moderate (35.9%), while 11 were classified as Proliferative (28.2%). For 13 of the 14 Severe-to-Moderate cases, all three models predicted Moderate. The comparison with the OOF results is descriptive, as the two sets contain different samples and the prediction protocols differ: the test predictions used four-view test-time augmentation, whereas the OOF predictions were generated from a single view. Furthermore, because the test set contains only 39 Severe images, these proportions should be interpreted cautiously.
The Severe-class misclassifications are also summarized in Table 13. Among the 154 OOF images with a severe label, 71 were misclassified, corresponding to 46.1% of Severe cases. Most errors involved adjacent severity levels: 41 Severe images were under-graded as Moderate, while 28 were over-graded as Proliferative. Only two severe cases were misclassified as Mild. Overall, 69 of the 71 Severe-class errors (97.2%) involved immediately adjacent grades, indicating that the principal difficulty was distinguishing the boundary between Moderate, Severe, and Proliferative DR rather than confusing Severe cases with substantially lower disease stages.
Table 13.
Ordinal error distribution and Severe-class misclassification patterns of the best ensemble model evaluated on the OOF predictions.
The agreement analysis among SwinV2, EVA-02, and ConvNeXtV2 is summarized in Table 14. Among the 413 ensemble errors on the OOF predictions, 197 (47.7%) were unanimous-wrong, 34 (8.2%) were all-wrong disagreements, and 182 (44.1%) were split-decision errors. On the held-out APTOS test set, unanimous-wrong errors accounted for 64 of 99 errors (64.6%), compared with 47.7% on OOF. These results indicate that shared incorrect predictions constituted a larger proportion of ensemble errors on the held-out test set. However, this comparison is descriptive and does not establish a statistically significant difference.
Table 14.
Distribution of ensemble misclassification categories on the APTOS OOF predictions and independent test set.
4. Discussion
This work investigated a multi-architecture ordinal learning framework for five-class diabetic retinopathy grading, with particular attention to class imbalance and the recognition of underrepresented severity grades. The framework combined SwinV2, EVA-02, and ConvNeXtV2 using equal-weight soft voting, multi-source training, APTOS-specific adaptation, and ordinal classification. The three-model ensemble achieved the highest Macro-F1 among the evaluated configurations in the OOF analysis. However, this advantage was not consistently observed on the held-out test set. Furthermore, nested validation showed that learned weighting and stacking did not consistently outperform equal-weight soft voting. The difference between OOF and held-out test performance may partly reflect the optimization of CORAL thresholds on the same OOF predictions used for evaluation. In addition, OOF predictions were generated using a single view, whereas held-out test predictions used four-view TTA and fold averaging. Therefore, the relative contribution of threshold selection and differences in inference procedures cannot be determined from the current experiments.
The near-duplicate sensitivity analysis showed modest changes in performance after excluding 54 potentially overlapping test images. EVA-02 maintained the highest Macro-F1 and Severe-class F1 among the four evaluated systems, while the three-model ensemble showed slight decreases in both metrics. The 95% confidence intervals for the changes included zero for both systems. However, patient-level independence could not be fully verified due to unavailable patient identifiers.
A key finding was the gap between overall classification performance and Severe-class recognition. The final ensemble achieved substantially higher aggregate F1 than Severe-class F1, indicating that overall metrics alone may not fully reflect the difficulty of recognizing this clinically important grade. The ordinal error analysis showed that 83.1% of the 413 incorrect OOF predictions differed from the true class by only one severity grade, while 98.5% differed by no more than two grades. For Severe DR, 69 of 71 errors were classified as either Moderate or Proliferative DR. Thus, the remaining errors were predominantly concentrated around neighboring severity boundaries rather than being distributed in widely separated disease stages. This pattern suggests that the main residual challenge lies in distinguishing visually similar adjacent stages of disease severity.
The results of the present study were within the range of those reported in previous five-class DR studies summarized in Table 15. However, direct numerical comparisons should be interpreted cautiously because the previous studies used different dataset splits, preprocessing pipelines, augmentation strategies, training configurations, and evaluation protocols. Therefore, this comparison provides context for interpreting the results rather than a direct ranking of methods.
Table 15.
Comparison of the proposed framework with previous studies for five-class diabetic retinopathy grading on APTOS 2019.
The ensemble experiments highlighted differences between OOF and held-out test performance. The three-model ensemble achieved the highest OOF Macro-F1 and Severe-class F1 among the evaluated configurations, suggesting partially complementary predictions across the architectures. However, this advantage was not confirmed on the independent test set. Similarly, improvements from optimized ensemble weights during the initial OOF search did not persist under nested validation. None of the evaluated stacking approaches outperformed equal-weight soft voting in the nested comparison. These findings support equal-weight soft voting as a simpler aggregation strategy that performed comparably to more complex alternatives under the evaluated conditions.
The controlled ablation study showed varying performance across the evaluated classification approaches. CORAL with focal loss achieved the highest QWK on the independent test set, while CORAL without focal loss achieved a higher Macro-F1 and Severe-class F1. However, the observed differences in Macro-F1 and Severe-class F1 were not statistically significant. These findings suggest that CORAL-based classification may improve agreement across ordered DR severity grades under the evaluated EVA-02 configuration, although consistent improvements in overall classification performance were not observed.
Multi-source training slightly increased Macro-F1 for EVA-02, while Severe-class F1 decreased in the OOF analysis (Table 9). These differences were not statistically tested and may reflect run-to-run variability or differences in class distributions. Similarly, APTOS-specific fine-tuning was associated with a slight performance decrease on EyePACS (Table 12). Although differences in image characteristics were observed, domain shift cannot be established as the cause of these changes. Moreover, the EyePACS performance estimates may be optimistically biased due to fellow-eye overlap between the training and test subsets. After excluding 800 affected test images, Macro-F1 decreased from 0.6467 to 0.6104, although changes in test-set composition may also have contributed to this decrease.
The distribution of ensemble errors provides further insight into the model’s limitations. Of the 413 incorrect predictions, 197 (47.7%) were unanimous-wrong cases, 34 (8.2%) were all-wrong disagreement cases, and 182 (44.1%) were split-decision cases. Unanimous-wrong cases may reflect ambiguous retinal features or limitations shared across the three architectures. In split-decision cases, at least one model predicted the correct grade, but the ensemble did not. In all-wrong disagreement cases, none of the individual models predicted the correct grade. These patterns may motivate future research on uncertainty estimation and confidence-aware ensemble aggregation.
To analyze explainability, we selected three Severe OOF cases representing different prediction patterns: one all-correct case, one split-decision case, and one unanimous-wrong case. We examined each case individually using SwinV2, EVA-02, and ConvNeXtV2, generating nine Grad-CAM visualizations and nine LIME explanations. This allowed us to qualitatively compare the attribution patterns of the three architectures across correct predictions, shared errors, and model disagreements.
Grad-CAM visualizations were examined to compare the spatial attribution patterns of SwinV2, EVA-02, and ConvNeXtV2 across the three selected Severe cases. As illustrated in Figure 4, the correctly classified case showed highlighted regions distributed within the retinal field, with different activation patterns across the three models. In the split-decision case, EVA-02 correctly predicted Severe, whereas SwinV2 and ConvNeXtV2 predicted Moderate. Their Grad-CAM maps highlighted different retinal regions, including central, inferior, and peripheral areas. In the unanimous-wrong case, all three models incorrectly predicted Proliferative, with activations distributed across the retinal field and, particularly for EVA-02, near the image boundaries. These examples illustrate differences in the regions emphasized by the models. However, each category was represented by only one case, and no conclusions about general attention patterns or model reasoning can be drawn.
Figure 4.
Representative Grad-CAM explanations for three Severe OOF cases: all-correct (first row), split-decision (second row), and unanimous-wrong (third row). Each model panel shows the ground-truth grade, predicted grade, and predicted-class probability. Warmer colors indicate higher relative Grad-CAM responses, whereas cooler colors indicate lower responses.
To compare LIME and Grad-CAM, LIME explanations were generated for the same three Severe OOF cases previously analyzed with Grad-CAM. As illustrated in Figure 5, LIME highlighted localized superpixel regions with positive and negative contributions to the predicted class, shown in green and red, respectively. Grad-CAM and LIME showed partial spatial agreement in some regions but emphasized different areas in others. Both methods explained the same target, namely the CORAL-decoded probability of the class predicted by each model. Therefore, differences between the visualizations may reflect their distinct explanation mechanisms rather than differences in the prediction target. Overall, these methods provided complementary qualitative views of model behavior, without establishing lesion-localization accuracy or clinical validity.
Figure 5.
Representative LIME explanations for the same three Severe OOF cases: all-correct (first row), split-decision (second row), and unanimous-wrong (third row). Each model panel shows the ground-truth grade, predicted grade, and predicted-class probability. Green regions indicate positive contributions, whereas red regions indicate negative contributions to the explained class prediction.
5. Conclusions
This study investigated a multi-architecture ordinal learning framework for five-class diabetic retinopathy grading using SwinV2, EVA-02, and ConvNeXtV2 with CORAL-based ordinal classification. By combining multi-source training, Ben Graham preprocessing, APTOS-specific adaptation, test-time augmentation, and ensemble prediction, the study examined not only overall classification performance but also the recognition of difficult severity grades and the behavior of different ensemble strategies. The results suggest that architectural diversity may provide complementary information, as observed in the OOF analysis, although this advantage was not confirmed on the held-out test set. The three-model combination achieved the strongest performance in the initial OOF analysis, while nested validation showed that equal-weight soft voting provided a reliable aggregation strategy. In contrast, learned weighting and stacking did not consistently improve performance, emphasizing that greater ensemble complexity does not necessarily translate into better validation performance. The error analysis further showed that most incorrect predictions occurred between nearby severity grades, with Severe DR remaining particularly challenging. This finding highlights the importance of reporting class-specific and ordinal error patterns rather than relying only on aggregate performance measures. The explainability analysis using Grad-CAM and LIME provided qualitative insights into model behavior across correct and incorrect predictions. Overall, the findings highlight the importance of evaluating ordinal learning and architectural diversity through rigorous validation, while emphasizing the remaining challenges in minority-class recognition.
Limitations and Future Directions
Several limitations should be considered. The limited number of Severe DR cases, particularly the 39 images in the held-out APTOS test set, restricts the precision of class-specific estimates. Although training incorporated APTOS, EyePACS, and Messidor-2, generalization to independently collected datasets and patient populations remains unestablished. Furthermore, patient-level independence could not be fully verified for APTOS and Messidor-2. Duplicate analysis identified 54 held-out test images with near-duplicates in the training data, 112 OOF images with near-duplicates in other folds, and 43 duplicate pairs with conflicting grades. The multi-source evaluation also included 800 EyePACS test images whose fellow eyes were present in training. Excluding these images changed performance, but the differences cannot be attributed solely to patient overlap because class distributions also changed.
Additional methodological limitations concern model validation and evaluation. OOF estimates may be optimistic because early stopping and checkpoint selection used the same validation folds, while thresholds were optimized using OOF predictions. Nested validation assessed ensemble combination and threshold selection rather than the complete training pipeline. Moreover, OOF predictions used a single view, whereas held-out test predictions used four-view TTA and fold averaging. The controlled CORAL ablation was limited to EVA-02 and a single random seed, and the fold-0 control involved only one retraining. No adjustment for multiple comparisons was applied. Finally, Grad-CAM and LIME provided qualitative explanations without expert-annotated lesion-level validation.
Future work should investigate patient-independent external validation, broader evaluation of minority classes, repeated ablation experiments across different architectures and random seeds, and quantitative assessment of explanations against expert annotations.
Author Contributions
H.A. (Hissah Alabbadi): conceptualization, methodology, software, validation, formal analysis, investigation, data curation, writing—original draft preparation, visualization; H.A. (Hind Almisbahi): writing—review and editing, supervision, project administration; H.A. (Hanan Alghamdi): writing—review and editing, supervision, project administration. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
The datasets used in this study are publicly available. The APTOS 2019 Blindness Detection dataset [14], the EyePACS dataset [39], and the Messidor-2 dataset [40] were obtained from their respective public sources. No new datasets were created as part of this study.
Acknowledgments
The project was funded by KAU Endowment (WAQF) at King Abdulaziz University, Jeddah, Saudi Arabia. The authors, therefore, acknowledge with thanks WAQF and the Deanship of Scientific Research (DSR) for their technical and financial support.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Guefrachi, S.; Echtioui, A.; Hamam, H. Diabetic retinopathy detection using deep learning multistage training method. Arab. J. Sci. Eng. 2025, 50, 1079–1096. [Google Scholar] [CrossRef] [Scilit]
- Saleh, I.; El-Den, N.N.; Elsharkawy, M.; Mahmoud, A.; Sewelam, A.; Wang, W.; Ghazal, M.; El-Baz, A. AI-based methods for diagnosing and grading diabetic retinopathy: A comprehensive review. Artif. Intell. Med. 2025, 168, 103221. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Hai, Z.; Zou, B.; Xiao, X.; Peng, Q.; Yan, J.; Zhang, W.; Yue, K. A novel approach for intelligent diagnosis and grading of diabetic retinopathy. Comput. Biol. Med. 2024, 172, 108246. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Romero-Oraá, R.; Herrero-Tudela, M.; López, M.I.; Hornero, R.; García, M. Attention-based deep learning framework for automatic fundus image processing to aid in diabetic retinopathy grading. Comput. Methods Programs Biomed. 2024, 249, 108160. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Araque-Gallardo, J.; Arrieta-Rodríguez, E.; Rueda-Gómez, L.; Teherán-Forero, O.; De-La-Hoz-Franco, E.; Gamarra, M.; Sierra-Carrillo, J.; Escorcia-Gutierrez, J. A systematic review on deep learning techniques for diabetic retinopathy classification in retinal fundus images. iScience 2026, 29, 116565. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Cao, W.; Mirjalili, V.; Raschka, S. Rank Consistent Ordinal Regression for Neural Networks with Application to Age Estimation. Pattern Recognit. Lett. 2020, 140, 325–331. [Google Scholar] [CrossRef] [Scilit]
- Gu, Z.; Li, Y.; Wang, Z.; Kan, J.; Shu, J.; Wang, Q. Classification of diabetic retinopathy severity in fundus images using the vision transformer and residual attention. Comput. Intell. Neurosci. 2023, 2023, 1305583. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Li, F.; Wang, Y.; Xu, T.; Dong, L.; Yan, L.; Jiang, M.; Zhang, X.; Jiang, H.; Wu, Z.; Zou, H. Deep learning-based automated detection for diabetic retinopathy and diabetic macular oedema in retinal fundus photographs. Eye 2022, 36, 1433–1441. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Wei, H.; Shi, P.; Miao, J.; Zhang, M.; Bai, G.; Qiu, J.; Liu, F.; Yuan, W. Caudr: A causality-inspired domain generalization framework for fundus-based diabetic retinopathy grading. Comput. Biol. Med. 2024, 175, 108459. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Ran, J.; Zhang, G.; Xia, F.; Zhang, X.; Xie, J.; Zhang, H. Source-free active domain adaptation for diabetic retinopathy grading based on ultra-wide-field fundus images. Comput. Biol. Med. 2024, 174, 108418. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Liu, Z.; Hu, H.; Lin, Y.; Yao, Z.; Xie, Z.; Wei, Y.; Ning, J.; Cao, Y.; Zhang, Z.; Dong, L.; et al. Swin Transformer V2: Scaling Up Capacity and Resolution. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), New Orleans, LA, USA, 18–24 June 2022; pp. 12009–12019. [Google Scholar] [CrossRef] [Scilit]
- Fang, Y.; Sun, Q.; Wang, X.; Huang, T.; Wang, X.; Cao, Y. Eva-02: A visual representation for neon genesis. Image Vis. Comput. 2024, 149, 105171. [Google Scholar] [CrossRef] [Scilit]
- Woo, S.; Debnath, S.; Hu, R.; Chen, X.; Liu, Z.; Kweon, I.S.; Xie, S. ConvNeXt V2: Co-Designing and Scaling ConvNets with Masked Autoencoders. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Vancouver, BC, Canada, 18–22 June 2023; pp. 16133–16142. [Google Scholar] [CrossRef] [Scilit]
- Asia Pacific Tele-Ophthalmology Society. APTOS 2019 Blindness Detection. Kaggle Competition, 2019. Available online: https://www.kaggle.com/c/aptos2019-blindness-detection (accessed on 17 February 2026).
- Mardianta, S.; Affandy; Supriyanto, C.; Wijaya, A.; Soeleman, M.A. Diabetic retinopathy detection based on convolutional neural networks with SMOTE and CLAHE techniques applied to fundus images. In Proceedings of the 2025 5th International Conference on Electronic and Electrical Engineering and Intelligent System (ICE3IS), Yogyakarta, Indonesia, 6–7 August 2025; IEEE: Piscataway, NJ, USA, 2025; pp. 13–18. [Google Scholar]
- Kasim, Ö. Ensemble classification based optimized transfer learning feature method for early stage diagnosis of diabetic retinopathy. J. Ambient. Intell. Humaniz. Comput. 2023, 14, 11337–11348. [Google Scholar] [CrossRef] [Scilit]
- Ahmed, F. Addressing high class imbalance in multi-class diabetic retinopathy severity grading with augmentation and transfer learning. arXiv 2025, arXiv:2507.17121. [Google Scholar]
- Farag, M.M.; Fouad, M.; Abdel-Hamid, A.T. Automatic severity classification of diabetic retinopathy based on densenet and convolutional block attention module. IEEE Access 2022, 10, 38299–38308. [Google Scholar] [CrossRef] [Scilit]
- Yu, W.; Si, X.; Zhong, J. Dual-SwinOrd: A Dual-Head Swin Transformer with Semantic Prior Injection for Ordinal Diabetic Retinopathy Grading. Bioengineering 2026, 13, 374. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- ElAdel, A.; Filali, I.; Zaied, M. Artificial intelligence for early detection of diabetic retinopathy: A vision transformer-based approach. PLoS ONE 2026, 21, e0350854. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Yang, Y.; Cai, Z.; Qiu, S.; Xu, P. A novel transformer model with multiple instance learning for diabetic retinopathy classification. IEEE Access 2024, 12, 6768–6776. [Google Scholar] [CrossRef] [Scilit]
- Rizvana, M.; Narayanan, S. Enhanced transformer network with high-dimensional attention mechanism for diabetic retinopathy classification. IEEE Access 2025, 13, 126307–126318. [Google Scholar] [CrossRef] [Scilit]
- Wang, Y.; Shen, S.; Tong, N. JFSP-ViT: A joint frequency-spatial perception vision transformer for diabetic retinopathy grading. IEEE Access 2025, 13, 150348–150364. [Google Scholar] [CrossRef] [Scilit]
- Liu, Y.; Yao, D.; Ma, Y.; Wang, H.; Wang, J.; Bai, X.; Zeng, G.; Liu, Y. STMF-DRNet: A multi-branch fine-grained classification model for diabetic retinopathy using Swin-TransformerV2. Biomed. Signal Process. Control 2025, 103, 107352. [Google Scholar] [CrossRef] [Scilit]
- Bhoopalan, R.; Sekar, P.; Nagaprasad, N.; Mamo, T.R.; Krishnaraj, R. Task optimized vision transformer for diabetic retinopathy detection and classification in resource constrained early diagnosis settings. Sci. Rep. 2025, 15, 39047. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Palaniappan, D.; Mohan, N.; Premavathi, T.; Gulzar, Y.; Ali, M.; Mir, M.S. Swin-DRNet: A robust transformer framework for diabetic retinopathy screening under heterogeneous imaging conditions. Sci. Rep. 2026, 16, 26623. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Boulaabi, M.; Gader, T.B.A.; Echi, A.K.; Bouraoui, Z. Enhancing DR classification with Swin transformer and shifted window attention. In Proceedings of the International Conference on Artificial Intelligence in Medicine, Pavia, Italy, 23–26 June 2025; Springer: Heidelberg, Germany, 2025; pp. 57–61. [Google Scholar]
- Maaod, Y.; Abuhmed, T.; Amer, E.; El-Sappagh, S. Hybrid deep ensemble architecture for robust diabetic retinopathy classification: Leveraging transfer learning and CNN-transformer synergy. Sci. Rep. 2026, 16, 26232. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Ataş, İ. Reti-TransNet: An adaptive gated hybrid framework for diabetic retinopathy grading. Eng. Sci. Technol. Int. J. 2026, 81, 102469. [Google Scholar] [CrossRef] [Scilit]
- Touati, M.; Touati, R.; Nana, L.; Benzarti, F.; Ben Yahia, S. DRCCT: Enhancing diabetic retinopathy classification with a compact convolutional transformer. Big Data Cogn. Comput. 2025, 9, 9. [Google Scholar] [CrossRef] [Scilit]
- Wang, Y.; Gou, X.; Li, W. CAD-ViT: Coordinate attention-enhanced vision transformer with dilated feature fusion for diabetic retinopathy staging. IEEE Access 2025, 13, 91505–91514. [Google Scholar] [CrossRef] [Scilit]
- Gou, X.; Wang, Y.; Li, W. LSD-HybridViT: A hybrid vision transformer with lightweight mixed-domain attention and frequency multi-scale dilated convolution feature fusion for diabetic retinopathy grading. IEEE Access 2025, 13, 167501–167511. [Google Scholar] [CrossRef] [Scilit]
- Ghadai, K.K.; Nayak, S.K.; Senapati, B.R. A clinically interpretable deep learning pipeline for diabetic retinopathy classification using EfficientNet, advanced data augmentation and GradCAM. BMC Ophthalmol. 2026, 26, 406. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Sekar, P.; Suba Raja, K.S.; Krishnaraj, R. DRCNN-Lesion Proxy: A hybrid CNN with lesion-inspired feature simulation for diabetic retinopathy severity classification. Sci. Rep. 2025, 15, 37954. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Yi, S.; Yang, C.; Ma, L. L-MedViT: A hierarchical hybrid network for fine-grained diabetic retinopathy grading. Image Vis. Comput. 2026, 170, 105970. [Google Scholar] [CrossRef] [Scilit]
- Zhang, W.; Belcheva, V.; Ermakova, T. Interpretable deep learning for diabetic retinopathy: A comparative study of CNN, ViT, and hybrid architectures. Computers 2025, 14, 187. [Google Scholar] [CrossRef] [Scilit]
- Ikram, A.; Imran, A. ResViT FusionNet Model: An explainable AI-driven approach for automated grading of diabetic retinopathy in retinal images. Comput. Biol. Med. 2025, 186, 109656. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Al Shafi, A.; Shawon, M.H.; Shahid, N.; Rahman, R.; Khan, R. Enhancing diabetic retinopathy detection through transformer based knowledge distillation and explainable AI. In Proceedings of the 2024 International Joint Conference on Neural Networks (IJCNN), Yokohama, Japan, 30 June–5 July 2024; IEEE: Piscataway, NJ, USA, 2024; pp. 1–8. [Google Scholar]
- Kaggle and EyePACS. Diabetic Retinopathy Detection. Kaggle Competition, 2015. Available online: https://www.kaggle.com/c/diabetic-retinopathy-detection (accessed on 7 August 2026).
- LaTIM Laboratory and Messidor Program Partners. Messidor-2 Dataset. Available online: https://www.adcis.net/en/third-party/messidor2/ (accessed on 28 October 2026).
- Graham, B. Kaggle Diabetic Retinopathy Detection Competition Report; Technical report; University of Warwick: Coventry, UK, 2015. [Google Scholar]
- Singh, J.; Beeche, C.; Shi, Z.; Beale, O.; Rosin, B.; Leader, J.; Pu, J. Batch-balanced focal loss: A hybrid solution to class imbalance in deep learning. J. Med. Imaging 2023, 10, 051809. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Bradshaw, T.J.; Huemann, Z.; Hu, J.; Rahmim, A. A guide to cross-validation for artificial intelligence in medical imaging. Radiol. Artif. Intell. 2023, 5, e220232. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Wainer, J.; Cawley, G. Nested cross-validation when selecting classifiers is overzealous for most practical applications. Expert Syst. Appl. 2021, 182, 115222. [Google Scholar] [CrossRef] [Scilit]
- Efron, B.; Tibshirani, R.J. An Introduction to the Bootstrap; Chapman and Hall: New York, NY, USA, 1993. [Google Scholar]
- Selvaraju, R.R.; Cogswell, M.; Das, A.; Vedantam, R.; Parikh, D.; Batra, D. Grad-CAM: Visual Explanations from Deep Networks via Gradient-Based Localization. In Proceedings of the IEEE International Conference on Computer Vision (ICCV), Venice, Italy, 22–29 October 2017; pp. 618–626. [Google Scholar] [CrossRef] [Scilit]
- Ribeiro, M.T.; Singh, S.; Guestrin, C. “Why Should I Trust You?”: Explaining the Predictions of Any Classifier. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, San Francisco, CA, USA, 13–17 August 2016; ACM: New York, NY, USA, 2016; pp. 1135–1144. [Google Scholar] [CrossRef] [Scilit]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.




