DiffuPT: Class Imbalance Mitigation for Glaucoma Detection via Diffusion Based Generation and Model Pretraining

Youssof Nawar, Nouran Soliman, Moustafa Wassel, Mohamed ElHabebe, Noha Adly, Marwan Torki, Ahmed Elmassry, Islam Ahmed

Abstract

Glaucoma is a progressive optic neuropathy characterized by structural damage to the optic nerve head and functional changes in the visual field. Detecting glaucoma early is crucial to preventing loss of eyesight. However, medical datasets often suffer from class imbalances, making detection more difficult for deep-learning algorithms. We use a generative-based framework to enhance glaucoma diagnosis, specifically addressing class imbalance through synthetic data generation. In addition, we collected the largest national dataset for glaucoma detection to support our study. The imbalance between normal and glaucomatous cases leads to performance degradation of classifier models. By combining our proposed framework leveraging diffusion models with a pretraining approach, we created a more robust classifier training process. This training process results in a better-performing classifier. The proposed approach shows promising results in improving the harmonic mean (sensitivity and specificity) and AUC for the roc for the glaucoma classifier. We report an improvement in the harmonic mean metric from 89.09% to 92.59% on the test set of our national dataset. We examine our method against other methods to overcome imbalance through extensive experiments. We report similar improvements on the AIROGS dataset. This study highlights that diffusion-based generation can be of great importance in tackling class imbalances in medical datasets to improve diagnostic performance.

Introduction

Glaucoma is a leading cause of permanent blindness worldwide. While deep learning has shown immense potential in medical imaging, its application in ophthalmology is often hindered by the low prevalence of the disease—affecting only about 3.5% of the general population. This rarity creates a significant class imbalance in clinical datasets. Models trained on such data often achieve high accuracy by simply predicting the majority "normal" class, resulting in poor sensitivity for actual glaucoma cases.

To address this, we introduce DiffuPT (Diffusion Based Generation and Model Pretraining) and present the GlaucomaEgy dataset, the largest national dataset for glaucoma in Egypt, containing 37,253 gradable fundus images. Our approach leverages the high-fidelity generation capabilities of diffusion models to balance datasets and improve diagnostic performance.

Methods

The DiffuPT framework consists of a four-stage pipeline designed to mitigate class imbalance through high-quality synthetic data:

  1. Generation: We utilize a Latent Diffusion Model (LDM). By operating in a compressed latent space rather than raw pixels, LDMs generate high-resolution images efficiently while capturing complex retinal structures.
  2. Filtering: Synthetic images are passed through a baseline classifier. Only images that are clearly and correctly identified as the target class (glaucoma or normal) are retained, ensuring the quality of the training signal.
  3. Pre-training: A Swin Transformer classifier is pre-trained on a perfectly balanced synthetic dataset. This stage allows the model to learn robust disease features without the bias inherent in imbalanced real-world data.
  4. Fine-tuning: The model is finally fine-tuned on the real, imbalanced dataset using a lower learning rate to ground its learned representations in clinical reality.
The DiffuPT framework: A Latent Diffusion Model generates synthetic images from noise and class labels, which are then filtered by a Swin Classifier to ensure high-quality, correctly labeled data for the generated dataset.

Key Insights and Results

Our experiments revealed several critical advantages of the DiffuPT approach:

  • Diffusion vs. GANs: Diffusion models significantly outperformed Generative Adversarial Networks (GANs) like CycleGAN and StarGANv2. Qualitatively, LDMs achieved a Fréchet Inception Distance (FID) of 7.94, compared to 39.76 for the best GAN, indicating much higher realism and better capture of ethnic variations in retinal appearance.
  • The Power of Pre-training: Pre-training on synthetic data proved superior to simple data augmentation. It allowed the model to develop stable embeddings with lower variance, preventing it from being overwhelmed by the majority class during the final training phase.
  • Performance Gains: On the GlaucomaEgy dataset, DiffuPT improved the harmonic mean (a balanced metric of sensitivity and specificity) from a baseline of 89.09% to 92.59%. It also outperformed standard techniques like Weighted Cross-Entropy (91.48%) and Weighted Sampling (91.00%).
  • Diminishing Returns: We observed that performance peaks when adding approximately 2,000–3,000 synthetic samples. Beyond this point, performance slightly degrades as the model begins to overfit to the specific characteristics of the generative model.
Performance comparison (Harmonic Mean) across different generative models and sample sizes. Diffusion-based methods (DDPM and LDM) consistently outperform GAN-based alternatives and the 'No Augmentation' baseline.

Conclusion

DiffuPT demonstrates that diffusion-based generation is a highly effective strategy for tackling class imbalance in medical imaging. By combining high-fidelity generation with a strategic pre-training phase, we achieved state-of-the-art diagnostic performance on both national and international benchmark datasets. Future work will focus on optimizing generation speed, as the current diffusion process remains computationally intensive compared to GAN-based methods.

Summary updated

Abstract

Glaucoma is a progressive optic neuropathy characterized by structural damage to the optic nerve head and functional changes in the visual field. Detecting glaucoma early is crucial to preventing loss of eyesight. However, medical datasets often suffer from class imbalances, making detection more difficult for deep-learning algorithms. We use a generative-based framework to enhance glaucoma diagnosis, specifically addressing class imbalance through synthetic data generation. In addition, we collected the largest national dataset for glaucoma detection to support our study. The imbalance between normal and glaucomatous cases leads to performance degradation of classifier models. By combining our proposed framework leveraging diffusion models with a pretraining approach, we created a more robust classifier training process. This training process results in a better-performing classifier. The proposed approach shows promising results in improving the harmonic mean (sensitivity and specificity) and AUC for the roc for the glaucoma classifier. We report an improvement in the harmonic mean metric from 89.09% to 92.59% on the test set of our national dataset. We examine our method against other methods to overcome imbalance through extensive experiments. We report similar improvements on the AIROGS dataset. This study highlights that diffusion-based generation can be of great importance in tackling class imbalances in medical datasets to improve diagnostic performance.
BibTeX
@inproceedings{nawar2025diffupt,
  author = {Youssof Nawar and Nouran Soliman and Moustafa Wassel and Mohamed ElHabebe and Noha Adly and Marwan Torki and Ahmed Elmassry and Islam Ahmed},
  title = {{DiffuPT: Class Imbalance Mitigation for Glaucoma Detection via Diffusion Based Generation and Model Pretraining}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2025},
  url = {https://openreview.net/forum?id=ew1xdSTPEM},
}
Figure