API Reference
Auto-generated reference for the brain_mri_segmentation package via mkdocstrings. Each module below lists its public classes and functions with their docstrings and type signatures.
Package root
brain_mri_segmentation
Production-grade binary brain-tumor MRI segmentation (LGG / TCGA).
Data
datamodule
Lightning DataModule for binary brain-MRI segmentation.
dataset
Paired (image, mask) TIF dataset for binary segmentation.
Functions
prepare
Patient-level train/val/test split for the LGG Brain MRI dataset.
Functions
file_sha256
file_sha256(path: Path) -> str
Hash a source file without retaining its payload in memory.
Source code in src/brain_mri_segmentation/data/prepare.py
18 19 20 21 | |
build_split_manifest
build_split_manifest(
raw: Path, *, seed: int, val_frac: float, test_frac: float
) -> dict
Validate paired files and record the exact deterministic patient split.
Source code in src/brain_mri_segmentation/data/prepare.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
Models
factory
Model factory - returns a segmentation model by name.
lightning_module
Lightning module wrappers.
Classes
unet
Small U-Net (4 levels, 32->256 ch) for binary segmentation.
Training
train
Training entrypoint (Hydra-powered).
Evaluation
evaluate
Evaluation CLI: explicit foreground metrics and verified split lineage.
Functions
Inference
predict
Inference CLI - load a checkpoint and predict a binary mask.
Functions
load_model
load_model(checkpoint_path: str | Path)
Load a Lightning module from checkpoint, rebuilding the backbone from hparams.
Source code in src/brain_mri_segmentation/inference/predict.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
Serving
dependencies
Dependency injection - singleton model loader.
Functions
errors
Exception types and handlers.
main
FastAPI application.
routes
FastAPI routes.
schemas
Pydantic request/response schemas.
Utilities
hf_hub
HuggingFace Hub helpers.
logging
Structured logging configuration.
seed
Deterministic seeding across libraries.