Skip to content

Applied research, MBA in Artificial Intelligence and Big Data at ICMC-USP

Diabetic retinopathy across datasets

A measurement of how much image preprocessing sustains the generalization of convolutional networks when a model trained on one fundus dataset is applied, without adaptation, to another. Six configurations, three preprocessing strategies across two architectures, trained on 35,126 images and evaluated on 1,744 from a different source.

Role
Author, advised by Prof. Agma J. M. Traina
Period
2026
Status
Monograph completed, 58 pages
Chart of AUC drop across datasets: baseline 9.9%, CLAHE 7.0% and green channel 0.2%.

Architecture

  • A cross-dataset protocol: training exclusively on EyePACS and evaluating on Messidor-2, with no adaptation. No Messidor-2 image takes part in training or in checkpoint selection.
  • Labels binarized by the same rule on both datasets: grade 0 of the severity scale becomes the negative class, grades 1 to 4 the positive class, which matches the refer or do-not-refer decision.
  • A within-dataset split grouped by patient: 17,563 EyePACS patients, two eyes each, split into 14,050 for training and 3,513 for validation, with zero patient overlap and 26.5% positives on both sides.
  • Three preprocessing strategies compared: plain resizing as the baseline, local contrast enhancement with CLAHE on the L channel of LAB space, and green channel extraction replicated across the three channels.
  • Two architectures of different capacity: a SimpleCNN with 1,146,561 parameters trained from scratch, with a 36 by 36 pixel receptive field, and an EfficientNet-B0 with 4,008,829 parameters initialized from ImageNet, fine-tuned end to end.
  • An identical training recipe across variants: BCEWithLogitsLoss with pos_weight 2.77, AdamW, CosineAnnealingLR, an effective batch of 32 through gradient accumulation, mixed precision, and augmentation by flips, rotation and brightness jitter.
  • Metrics with 95% confidence intervals from a 2,000-replicate bootstrap: AUC-ROC, sensitivity, specificity, precision, F1 and the confusion matrix.
  • Two operating points reported: the default 0.5 threshold and a threshold calibrated on validation for a minimum sensitivity of 0.90, then transferred to the external dataset with no readjustment.
  • Grad-CAM implemented with hooks on the last convolutional layer, shared between the monograph figure and a Gradio web demo that loads the six checkpoints.

Implementation details

  • The filter runs at native resolution and only then does the image go down to 512 by 512, because CLAHE depends on neighbourhood statistics and a microaneurysm covers few pixels in the original.
  • Confidence intervals come from a bootstrap that resamples the 874 exams rather than loose images, because 86.3% of eye pairs carry concordant labels.
  • The best checkpoint is picked by EyePACS validation AUC, never by the external dataset, and AUC is computed by a Mann-Whitney U statistic implemented in the project itself.

Technologies

Python
The language of the whole experiment, across thirteen scripts.
PyTorch
Training, fine-tuning and inference for both architectures.
torchvision
EfficientNet-B0 with ImageNet weights and the image transforms.
OpenCV
CLAHE on the L channel of LAB and green channel extraction.
NumPy e pandas
Handling labels, splits and results.
Pillow
Reading and resizing with Lanczos resampling.
matplotlib
ROC curves, confusion matrices and the monograph figures.
Grad-CAM
A hand-rolled implementation with hooks, to see where the network looks.
Gradio
A web demo that loads the six checkpoints and accepts an uploaded image.
EyePACS e Messidor-2
The training dataset and the external evaluation dataset.
  • Figure 6 of the monograph: the same fundus image without retinopathy, as baseline, CLAHE and green channel.
  • Figure 7: the same three variants applied to an image with diabetic retinopathy.
  • Figure 2: decomposition into colour channels, the motivation for choosing the green channel.
  • Figure 9: ROC curves on the external Messidor-2 set, by architecture and variant.
  • Figure 13: Grad-CAM maps on real retinopathy cases from Messidor-2.

Want to talk about architecture, technical decisions and shipping to production?

Portrait of Thiago Sanches

Contact details

Available for remote work with international teams

Name
Thiago Sanches
Location
Brazil · UTC−3 · remote
Languages
Portuguese native · professional working proficiency in English
Download résumé

Experience

  • 5 years

    on enterprise systems

  • 70%

    less time per new report

  • 50%

    less latency on GraphQL

  • Workers

    asynchronous processing with Redis queues