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.
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.
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
[CLAHE green, Frangi] stack, padded
to 608×608.0.5·BCE + 0.5·Dice — the Dice term handles the
~10:1 background/vessel imbalance.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/
DRIVE — Digital Retinal Images for Vessel Extraction, via Kaggle (original: grand-challenge).