How saadwazir/medcagd works
MedCAGD is a PyTorch medical-image segmentation project, configured by default for retinal vessel patches. Its main workflow is paired-image training, iterative validation-based checkpoint selection and early stopping, then final test evaluation and experiment summaries. The model combines a pretrained timm encoder with a custom context-aware decoder and auxiliary segmentation and edge outputs; training uses configurable losses and augmentation. Separate utilities patch images and reconstruct patch sets. The README documents the experiment stages; sampled source confirms key model, data, metric, and runner behavior, while some subsystem wiring is based on README documentation.
Main entry points: xrun.py Experiment runner · train.py Training loop · val_eval.py Validation evaluation · test_eval.py Test evaluation
Components 19
Experiment workflow
- Experiment settings
cfgs.py - Experiment runner
xrun.py - Training loop
train.py - Augmentation combinations
train_random_comb.csv - Early stopping
stopearly.py
Segmentation runtime
- Dataset loading and augmentation
data.py - Gated decoder model
model.py - Segmentation and edge losses
loss.py
Validation and results
- Best checkpoint selection
check_val.py - Validation evaluation
val_eval.py - Test evaluation
test_eval.py - Segmentation metrics
eval_metrics.py - Experiment results
Patch utilities
- Image patch extraction
patch.py - Patch reconstruction
unpatch.py
Other components
- Experiment user
- Paired image splits
- Pretrained timm encoder
- Patch files
Connections 35
- Experiment user → Experiment settings: configures
- Experiment user → Paired image splits: prepares
- Experiment user → Experiment runner: starts
- Experiment settings → Experiment runner: configures
- Experiment runner → Training loop: runs
- Experiment runner → Validation evaluation: runs
- Experiment runner → Best checkpoint selection: runs
- Experiment runner → Early stopping: runs
- Experiment runner → Test evaluation: runs
- Experiment runner → Augmentation combinations: cycles settings
- Experiment runner → Experiment results: writes summary
- Paired image splits → Dataset loading and augmentation: supplies splits
- Training loop → Dataset loading and augmentation: loads training data
- Training loop → Gated decoder model: trains
- Training loop → Segmentation and edge losses: computes loss
- Gated decoder model → Pretrained timm encoder: creates encoder
- Training loop → Experiment results: saves checkpoints
- Validation evaluation → Dataset loading and augmentation: loads validation data
- Validation evaluation → Gated decoder model: evaluates
- Validation evaluation → Segmentation metrics: computes metrics
- Validation evaluation → Experiment results: writes validation results
- Best checkpoint selection → Experiment results: reads validation scores
- Best checkpoint selection → Experiment results: records best checkpoint
- Early stopping → Experiment results: reads best score
- Early stopping → Experiment results: writes stop state
- Test evaluation → Dataset loading and augmentation: loads test data
- Test evaluation → Gated decoder model: evaluates
- Test evaluation → Segmentation metrics: computes metrics
- Test evaluation → Experiment results: writes test results
- Experiment user → Image patch extraction: runs utility
- Image patch extraction → Paired image splits: reads images and masks
- Image patch extraction → Patch files: writes patches
- Experiment user → Patch reconstruction: runs utility
- Patch files → Patch reconstruction: supplies patches
- Patch reconstruction → Experiment results: writes reconstructed images