GaNDLF

raw JSON →
0.1.5 verified Fri May 01 auth: no python

A generalizable AI framework for segmentation, regression, and classification in medical imaging, built on PyTorch. Current version 0.1.5, with releases on PyPI monthly. Supports multiple architectures and modalities.

pip install gandlf
error ModuleNotFoundError: No module named 'gandlf'
cause GaNDLF not installed or installed in wrong environment.
fix
Run 'pip install gandlf' in the correct Python environment.
error ImportError: cannot import name 'TrainingManager' from 'gandlf'
cause Incorrect import path; TrainingManager is in submodule.
fix
Use 'from gandlf.training_manager import TrainingManager'.
error RuntimeError: Could not find device. Please check CUDA availability.
cause Trying to run on GPU without CUDA or with incompatible PyTorch.
fix
Install PyTorch with CUDA support: 'pip install torch --index-url https://download.pytorch.org/whl/cu118'.
breaking Python version must be >3.9 and <3.13. Installing with Python 3.13+ will fail.
fix Use Python 3.10, 3.11, or 3.12.
deprecated Importing from gandlf directly (e.g., 'from gandlf import TrainingManager') is deprecated after v0.1.0.
fix Use full submodule path (e.g., 'from gandlf.training_manager import TrainingManager').
gotcha The config file must have absolute paths for data directories; relative paths may cause file-not-found errors.
fix Use os.path.abspath() or absolute paths in YAML.
breaking GaNDLF requires MONAI and PyTorch to be installed separately; pip does not automatically install them.
fix Run 'pip install torch monai' before installing gandlf.

Basic training with GaNDLF using a YAML config file. Replace paths as needed.

from gandlf import GANDLF
import os

gandlf_instance = GANDLF(
    config_path='path/to/config.yaml',
    data_path='path/to/data/'
)
gandlf_instance.train()
# For inference:
# gandlf_instance.infer(input='path/to/test.nii.gz')