A tested PyTorch framework for computational pathology research with working benchmarks on PatchCamelyon and CAMELYON16
View on GitHub matthewvaishnav/computational-pathology-research
Comprehensive documentation for the Computational Pathology Research Framework.
from src.data import PatchCamelyonDataset, CAMELYONSlideDataset
PatchCamelyonDataset: Patch-level image loadingCAMELYONSlideDataset: Slide-level feature loadingcollate_slide_bags: Variable-length batch collationfrom src.models import SimpleClassifier, SimpleSlideClassifier
from src.models.pretrained import load_pretrained_encoder
SimpleClassifier: Patch-level classifierSimpleSlideClassifier: Slide-level aggregationload_pretrained_encoder: Pretrained model loadingfrom src.training import train_epoch, evaluate
train_epoch: Single epoch training loopevaluate: Model evaluation with metricsfrom src.utils import set_seed, save_checkpoint, load_checkpoint
set_seed: Reproducibility utilitiessave_checkpoint: Model checkpointingload_checkpoint: Checkpoint loading# PCam training
python experiments/train_pcam.py --config experiments/configs/pcam.yaml
# CAMELYON training
python experiments/train_camelyon.py --config experiments/configs/camelyon.yaml
# PCam evaluation
python experiments/evaluate_pcam.py \
--checkpoint checkpoints/pcam/best_model.pth \
--data-root data/pcam
# CAMELYON evaluation with CSV export
python experiments/evaluate_camelyon.py \
--checkpoint checkpoints/camelyon/best_model.pth \
--save-predictions-csv
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=src --cov-report=html
# Profile inference time
python scripts/model_profiler.py \
--checkpoint models/best_model.pth \
--profile-type time
# Export to ONNX
python scripts/export_onnx.py \
--checkpoint models/best_model.pth \
--output models/model.onnx
nvidia-smiHistorical documentation and implementation notes are available in archive/.