journal article·2026-07-02Open access

Classification of Retinal OCT Images on an Imbalanced Dataset Using a Swin Transformer

Paweł Borkowski, Marian Wysocki, Andrzej Grzybowski, Anna Wiśniewska-Borkowska

Applied Sciences· Volume 16· Issue 13

Abstract

Small and severely imbalanced optical coherence tomography (OCT) datasets pose a major challenge for deep learning algorithms while reflecting the reality of smaller ophthalmology centers, where rare retinal pathologies such as retinal artery occlusion (RAO) and vitreomacular interface disease (VID) occur only sporadically. The experiments were performed on the imbalanced OCTDL dataset (seven classes, 2064 images) and on a custom imbalanced subset of OCT-C8 (eight classes) matching the OCTDL class distribution. An extended ablation of eight loss functions was carried out under 10-fold stratified cross-validation (CV). As the loss for the final Swin Transformer Base model, we adopt dual-weighted PolyLoss (DW-PolyLoss), a lightweight modification of PolyLoss in which inverse-frequency class weights are applied symmetrically to both the cross-entropy and the polynomial correction terms. Under 10-fold stratified CV, the mean OCTDL accuracy is 95.63%, and a logit-averaging ensemble of the 10-fold models reaches 96.71% accuracy on OCTDL and 96.21% on a custom imbalanced subset of OCT-C8 constructed to match the OCTDL class distribution. Score-CAM analysis suggests that the model attends to clinically interpretable retinal structures, supporting potential use as a screening-triage tool subject to prospective clinical validation.
Source: crossref · Quality: baseline

Research context

OpenAlex topics: Retinal Imaging and Analysis · Retinal and Optic Conditions · Retinal Diseases and Treatments

SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.

Affiliations

Doctoral School, Rzeszów University of Technology, W. Pola 2, 35-021 Rzeszów, Poland

Department of Computer and Control Engineering, Faculty of Electrical and Computer Engineering, Rzeszów University of Technology, W. Pola 2, 35-021 Rzeszów, Poland

Institute for Research in Ophthalmology, Foundation for Ophthalmology Development, ul. Mickiewicza 24/3B, 60-836 Poznań, Poland

Department of Ophthalmology, University of Warmia and Mazury, ul. Żołnierska 18, 10-561 Olsztyn, Poland

Doctoral School, Medical University of Lublin, Al. Racławickie 1, 20-059 Lublin, Poland

References (29)

Show source-provided references
1. World Health Organization (2019). World Report on Vision, World Health Organization. Available online: https://www.who.int/publications/i/item/9789241516570.
2. Global Causes of Blindness and Distance Vision Impairment 1990–2020: A Systematic Review and Meta-Analysis10.1016/S2214-109X(17)30393-5 ↗
3. Bille, J.F. (2019). Optical Coherence Tomography (OCT): Principle and Technical Realization. High Resolution Imaging in Microscopy and Ophthalmology: New Frontiers in Biomedical Optics, Springer.
4. Grzybowski, A. (2025). Artificial Intelligence in Ophthalmology: Promises, Hazards and Challenges. Artificial Intelligence in Ophthalmology, Springer. [2nd ed.].10.1007/978-3-031-83756-2 ↗
5. A Comprehensive Review of Deep Learning in OCT Image Segmentation and Classification10.1016/j.medntd.2025.100396 ↗
6. Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A.N., Kaiser, Ł., and Polosukhin, I. (2017). Attention Is All You Need. Proceedings of the Advances in Neural Information Processing Systems 30 (NeurIPS 2017), Long Beach, CA, USA, 4–9 December 2017, Curran Associates Inc.
7. Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer, M., Heigold, G., and Gelly, S. (2021, January 3–7). An Image Is Worth 16x16 Words: Transformers for Image Recognition at Scale. Proceedings of the 9th International Conference on Learning Representations (ICLR 2021), Virtual.
8. Liu, Z., Lin, Y., Cao, Y., Hu, H., Wei, Y., Zhang, Z., Lin, S., and Guo, B. (2021, January 10–17). Swin Transformer: Hierarchical Vision Transformer Using Shifted Windows. Proceedings of the 2021 IEEE/CVF International Conference on Computer Vision (ICCV), Montreal, QC, Canada.10.1109/ICCV48922.2021.00986 ↗
9. Dutta, P., Sathi, K.A., Hossain, M.A., and Dewan, M.A.A. (2023). Conv-ViT: A Convolution and Vision Transformer-Based Hybrid Feature Extraction Method for Retinal Disease Detection. J. Imaging, 9.10.3390/jimaging9070140 ↗
10. Saraei, M., Kozak, I., and Lee, E.-J. (2025). ViT-2SPN: Vision Transformer-Based Dual-Stream Self-Supervised Pretraining Networks for Retinal OCT Classification. arXiv.
11. Karn, P.K., and Abdulla, W.H. (November, January 31). Enhancing Retinal Disease Classification with Dual Scale Twin Vision Transformers Using OCT Imaging. Proceedings of the 2023 Asia Pacific Signal and Information Processing Association Annual Summit and Conference (APSIPA ASC), Taipei, Taiwan.10.1109/APSIPAASC58517.2023.10317338 ↗
12. A Systematic Study of the Class Imbalance Problem in Convolutional Neural Networks10.1016/j.neunet.2018.07.011 ↗
13. Cui, Y., Jia, M., Lin, T.Y., Song, Y., and Belongie, S. (2019, January 15–20). Class-Balanced Loss Based on Effective Number of Samples. Proceedings of the IEEE Computer Society Conference on Computer Vision and Pattern Recognition, Long Beach, CA, USA.10.1109/CVPR.2019.00949 ↗
14. Focal Loss for Dense Object Detection10.1109/TPAMI.2018.2858826 ↗
15. Cao, K., Wei, C., Gaidon, A., Arechiga, N., and Ma, T. (2019). Learning Imbalanced Datasets with Label-Distribution-Aware Margin Loss. Proceedings of the Advances in Neural Information Processing Systems 32 (NeurIPS 2019), Vancouver, BC, Canada, 8–14 December 2019, Curran Associates Inc.
16. Leng, Z., Tan, M., Liu, C., Cubuk, E.D., Shi, X., Cheng, S., and Anguelov, D. (2022, January 25–29). PolyLoss: A Polynomial Expansion Perspective of Classification Loss Functions. Proceedings of the 10th International Conference on Learning Representations (ICLR 2022), Virtual.
17. Identifying Medical Diagnoses and Treatable Diseases by Image-Based Deep Learning10.1016/j.cell.2018.02.010 ↗
18. OCTDL: Optical Coherence Tomography Dataset for Image-Based Deep Learning Methods10.1038/s41597-024-03182-7 ↗
19. Naren, O.S. (2026, June 21). Retinal OCT Image Classification—C8 [Data Set]. Kaggle, 2021. Available online: https://www.kaggle.com/datasets/obulisainaren/retinal-oct-c8.
20. Loshchilov, I., and Hutter, F. (2019, January 6–9). Decoupled Weight Decay Regularization. Proceedings of the 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA.
21. Brodersen, K.H., Ong, C.S., Stephan, K.E., and Buhmann, J.M. (2010, January 23–26). The Balanced Accuracy and Its Posterior Distribution. Proceedings of the 2010 20th International Conference on Pattern Recognition (ICPR), Istanbul, Turkey.10.1109/ICPR.2010.764 ↗
22. Weighted Kappa: Nominal Scale Agreement with Provision for Scaled Disagreement or Partial Credit10.1037/h0026256 ↗
23. Naeini, M.P., Cooper, G.F., and Hauskrecht, M. (2015, January 25–30). Obtaining Well Calibrated Probabilities Using Bayesian Binning. Proceedings of the AAAI Conference on Artificial Intelligence, Austin, TX, USA.
24. Guo, C., Pleiss, G., Sun, Y., and Weinberger, K.Q. (2017, January 6–11). On Calibration of Modern Neural Networks. Proceedings of the 34th International Conference on Machine Learning (ICML 2017), Sydney, Australia. PMLR 70.
25. Wang, H., Wang, Z., Du, M., Yang, F., Zhang, Z., Ding, S., Mardziel, P., and Hu, X. (2020, January 14–19). Score-CAM: Score-Weighted Visual Explanations for Convolutional Neural Networks. Proceedings of the 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW), Seattle, WA, USA.10.1109/CVPRW50498.2020.00020 ↗
26. Grad-CAM: Visual Explanations from Deep Networks via Gradient-Based Localization10.1007/s11263-019-01228-7 ↗
27. Kakumani, A.K., Tanuja, K., and Yetukuri, J.S. (2025, January 7–8). Vision Transformers for Retinal Disease Classification Using Optical Coherence Tomography Images. Proceedings of the 2025 International Conference on Computer, Electrical and Communication Engineering (ICCECE), Kolkata, India.10.1109/ICCECE61355.2025.10941428 ↗
28. An Interpretable Transformer Network for the Retinal Disease Classification Using Optical Coherence Tomography10.1038/s41598-023-30853-z ↗
29. Li, Z., Han, Y., and Yang, X. (2023). Multi-Fundus Diseases Classification Using Retinal Optical Coherence Tomography Images with Swin Transformer V2. J. Imaging, 9.10.3390/jimaging9100203 ↗