Overview
nnUNet (No New U-Net) is a self-configuring framework for medical image segmentation that automatically adapts to any dataset. Consistently top-performing on benchmarks like BraTS, KiTS, and AMOS.
Installation
uv pip install nnunetv2
Plan and Preprocess
nnUNetv2_plan_and_preprocess -d DATASET_ID -pl nnUNetPlanner
Train
nnUNetv2_train DATASET_ID CONFIG 0 # CONFIG: 2d, 3d_fullres, 3d_lowres
Inference
nnUNetv2_predict -i INPUT_FOLDER -o OUTPUT_FOLDER -d DATASET_ID -c CONFIG
Python API
from nnunetv2.inference.predict_from_raw_data import nnUNetPredictor
predictor = nnUNetPredictor()
predictor.initialize_from_trained_model_folder("nnUNet_results/DatasetXYZ", "3d_fullres")
predictor.predict_from_files("input_images", "output_segmentations")
Workflow
- Prepare dataset in nnUNet format (imagesTr, labelsTr, dataset.json)
- Run
nnUNetv2_plan_and_preprocessfor automatic configuration - Train with
nnUNetv2_train - Predict with
nnUNetv2_predictor Python API - Ensemble multiple configurations for best accuracy