Biomedical Signal Processing and Control
Improving diabetic retinopathy detection via uncertainty-based attention refinement in Swin Transformers
By Jegan Sivaraman and Arjun Paramarthalingam.
Abstract
Diabetic Retinopathy remains one of the leading causes of preventable vision impairment and blindness worldwide, necessitating timely and accurate diagnosis to mitigate irreversible damage. In this paper, we propose a deep learning framework for fine-grained DR stage classification that integrates a modified Swin Transformer architecture with an Uncertainty-Scaled Relative Attention (SRA) mechanism. The proposed SRA module estimates attention uncertainty across token interactions and adaptively amplifies attention weights in ambiguous or diagnostically challenging regions, promoting more reliable decision-making. To enhance the quality of input data and emphasize retinal features critical for classification such as hemorrhages, microaneurysms, exudates) we apply a specialized preprocessing pipeline using Contrast Limited Adaptive Histogram Equalization (CLAHE) and adaptive gamma correction. The Swin Transformer’s shifted-window multi-scale attention structure enables robust hierarchical feature extraction across varying spatial resolutions. By integrating the SRA mechanism, our model selectively re-attends to uncertain spatial regions, particularly improving performance on borderline classes such as Mild and Moderate DR. The model is evaluated on a balanced and augmented version of the APTOS 2019 dataset, with 500 high-quality images per class. Our system achieves performance with 97.34% accuracy, 97.35% sensitivity, 99.34% specificity, 97.37% precision, and a 97.34% F1-score. These results highlight the effectiveness of combining hierarchical vision transformers with uncertainty-guided attention for fine-grained retinal disease classification. Beyond accuracy, the inclusion of the SRA module enhances the interpretability and clinical trustworthiness of model predictions. Furthermore, Grad-CAM is employed to provide visual explanations of the model’s decisions, helping ophthalmologists understand and validate the highlighted retinal regions responsible for each classification outcome. This makes our approach a promising candidate for the right decision support in ophthalmology.




