DINO-style self-supervised pretraining for OCT B-scan images, plus curve head (LoRA) post-train stage.
dinoct/: Python package (models, data, training)configs/: YAML configs (merged:configs/ssl_default_config.yaml+configs/train/oct.yaml)scripts/: entrypoints and utilities
- Python:
>=3.12 - CUDA: single GPU
This repo uses uv:
uv sync
uv run python -m dinoct --helpDefault expected layout under data/oct/:
data/oct/raw/*.jpgdata/oct/background/*.jpgdata/oct/labeled/<image_stem>.txt(optional; marks an image as labeled)data/oct/extra/entries.npy(metadata cache; regenerated each run)
Each label file should contain either:
- 500 floats (one per column), or
- a 500×2 table
(x, y)(the second column is used).
You can change the dataset paths via the dataset string: OCT:root=<root>[:extra=<extra>] (see configs/train/oct.yaml).
In that string, root/extra refer to dataset directories (not the repo root).
The dataset name token is case-insensitive.
The interactive curve label editor requires matplotlib:
uv sync --extra label
uv run python scripts/data/curve_labeler.py --dir data/octuv run python -m dinoct \
--config configs/train/oct.yaml \
--output-dir outputs/run1 \
--steps 10000 \
--post-train-steps 0Outputs:
outputs/run1/pretrain/dinov3_pretrain.pthoutputs/run1/pretrain/train.log,metrics.csv,config_used.yaml
uv run python -m dinoct \
--config configs/train/oct.yaml \
--output-dir outputs/run1 \
--steps 10000 \
--post-train-steps 1000To run post-train only (with an existing pretrain checkpoint):
uv run python -m dinoct \
--config configs/train/oct.yaml \
--output-dir outputs/run1 \
--post-train-only \
--pretrained-backbone outputs/run1/pretrain/dinov3_pretrain.pth \
--post-train-steps 1000Outputs:
outputs/run1/post_train/fused_curve.pthoutputs/run1/post_train/fused_curve_best.pthoutputs/run1/post_train/val_summary.json(validation metrics for final + best checkpoint)
uv run python scripts/visualize.py \
--mode curve \
--curve-ckpt outputs/run1/post_train/fused_curve_best.pth \
--input path/to/image_or_dir \
--outdir outputs/vizuv run python scripts/export_model.py --model outputs/run1/post_train/fused_curve_best.pth --outdir exportsDataset are available from https://huggingface.co/datasets/rjbaw/oct and using the huggingface dataset loader.
Set train.dataset_path to OCT:hub=rjbaw/oct (or include root=... for local-first).
Apache-2.0.
This project includes alot of code derived from Meta Platforms, Inc. and affiliates' DINOv2 and DINOv3 repositories, licensed under the Apache License, Version 2.0.
