Abstract
Diabetic Retinopathy (DR) is a severe complication of diabetes that can lead to vision impairment
or blindness, making early detection crucial. Traditional deep learning models often struggle with
class imbalance in medical datasets, leading to poor performance for minority classes. This study
proposes a novel deep learning model based on Residual Networks (ResNet) to address the multi
class classification of DR, with a focus on mitigating class imbalance. Standard Softmax activation
functions tend to favor majority classes, thereby worsening the model's performance on minority
classes. To address this, the study incorporates a custom loss function, Balanced Softmax Loss,
which adjusts class weights to improve the recognition of minority classes. Additionally, the model
integrates advanced techniques such as Squeeze-and-Excitation (SE) blocks, learnable wavelet
transforms, and multi-head attention mechanisms to enhance feature extraction and model
performance. The model was trained and evaluated on the APTOS 2019 Blindness Detection
dataset, achieving a micro-average accuracy of 0.83 and a macro-average accuracy of 0.73 in the
5-class classification task. In a 4-class classification task, where severe and proliferative DR were
merged, the model achieved a micro-average accuracy of 0.87 and a macro-average accuracy of
0.84. The model's interpretability was further enhanced through Explainable AI (XAI) techniques
such as LIME, Grad-CAM, and SHAP. The trained model was deployed as a web-based
application using Flask, enabling real-time classification of retinal images. The study highlights
the model's effectiveness in addressing class imbalance and its potential for early DR diagnosis,
thereby enhancing clinical decision support.