← back to projects

Medical Imaging: Diabetic Retinopathy Screening

Python PyTorch EfficientNet-B3 OpenCV FastAPI Externally validated Research software

A screening tool that grades retina photos for diabetic retinopathy, built to fail safely: bad photos and borderline cases go to a human instead of getting a confident wrong answer.

My role: a solo project. I built everything: the image quality and anatomy checks, the model and its training, calibration, the grading web app, the audit log and the hospital deployment kit.

Try it: four real cases from the held-out test pick an image

    The decision rule: drag the dot

    operating point 0.67 ask a human
    0.00.51.0

    Real outputs of the served model on real photos it never saw: the 257 held-out IDRiD images that nothing was trained, calibrated or tuned on. One case per outcome, picked by a fixed rule (closest to its group's median score), not for looking good; across all 257, 18 referable eyes were still missed, which is why every output needs human review. The slider uses the decision rule the service serves: operating point 0.67, abstention band 0.29–0.91.
    Images: IDRiD © Prasanna Porwal, Samiksha Pachade and Manesh Kokare, CC BY 4.0; cropped and resized. Research software, not a medical device.

    Results: tested on a different hospital's images

    Trained on DeepDRiD (clinics in China), then tested on IDRiD, a clinic in India with different cameras and patients. The external numbers are the ones that matter: a model that only works on images like its training data is no use at a new site.

    0.938AUROC on 257 held-out external images (0.976 internal)
    88%of referable cases caught (sensitivity 0.882)
    85%of healthy eyes correctly cleared (specificity 0.854)
    Passedits own acceptance gate; the service refuses any model that fails it

    Design decisions, measured

    512 pxnot 224. A tiny lesion shrinks to 1.3 px at 224, indistinguishable from noise.
    142 / 400patients leaked into both train and test with a naive split. Splits are grouped by patient.
    0.102 → 0.031calibration error with isotonic. The popular choice (temperature) made it worse.
    Ordinalhead, so mistaking grade 4 for 0 costs far more than 3 for 4.

    Why it's built this way

    Ungradable is not negative. In real screening, 5–20% of photos are unusable, and a blurred image must never be quietly graded as "healthy". A learned quality model, trained on human quality ratings, decides gradability (AUROC 0.811, against 0.499 for a simple sharpness check), with classical checks as a backstop.

    It can say "I'm not sure". Cases near the decision boundary fall in an abstention band and go to a human grader, and every grader verdict is logged to detect drift after deployment.

    Built for a hospital network. Staff sign-in, encrypted image storage, a tamper-evident audit chain, FHIR and DICOM support, Docker packaging, HTTPS on the local network, and backups.

    Honest status. It is research software, not a medical device. The model is not plug-and-play: each new site needs its own labelled calibration sample first. The external test set is small, so its sensitivity could still be below the 0.85 target, and that has to be confirmed on a larger sample from the deploying site.