Retinal Vessel Segmentation

A from-scratch PyTorch U-Net that segments blood vessels in retinal fundus images, trained on the DRIVE dataset and served through a FastAPI overlay endpoint.

F1 0.83 AUC 0.98 U-Net · ResNet34 CLAHE + Frangi FastAPI · DRIVE
View on GitHub How it works

Results — inside field-of-view

From-scratch U-Net (default) on the 2-channel CLAHE+Frangi input; it beat the pretrained smp ResNet34 alternative at every patch size tried. Both clear the > 0.81 DRIVE benchmark.

0.834
F1 (Dice) · target > 0.81
0.845
Sensitivity
0.972
Specificity
0.980
AUC

Example

Original fundus image
Input — retinal fundus image
Predicted vessel overlay
Output — predicted vessels (red) + goodness scores

Method

RGB fundus image
  └─ CLAHE green channel    # channel 0 — contrast enhancement
  └─ Frangi vesselness      # channel 1 — Hessian tubularity prior
       └─ U-Net (pretrained ResNet34 encoder, or from-scratch)
            └─ 1×1 conv → sigmoid → vessel probability map

Goodness scores (no labels needed)

Run it

pip install -r requirements.txt
python train.py --epochs 150 --patch-size 48 --patches-per-epoch 8000
python evaluate.py --checkpoint checkpoints/unet_drive.pth
uvicorn app:app --port 8000   # then open http://localhost:8000/

Dataset

DRIVE — Digital Retinal Images for Vessel Extraction, via Kaggle (original: grand-challenge).