AI/TLDR

nnU-Net

Self-configuring deep learning for biomedical image segmentation

Overview

nnU-Net is a semantic segmentation framework that automatically adapts its pipeline to a dataset. It analyzes the training data, creates a dataset fingerprint, and configures suitable U-Net variants without you having to tune the setup by hand.

It is aimed at biomedical image segmentation and works with both 2D and 3D data, arbitrary channel definitions, and multiple image formats. The framework runs end to end, from preprocessing through training to inference, and is designed to train models from scratch on a new dataset.

nnU-Net is developed by the Applied Computer Vision Lab at Helmholtz Imaging and the Division of Medical Image Computing at DKFZ. It is released under the Apache-2.0 license, and the authors ask that work using it cite the 2021 Nature Methods paper by Isensee et al.

What it does

  • Automatically adapts its preprocessing, network, and training pipeline to a dataset
  • Analyzes training data and creates a dataset fingerprint to configure U-Net variants
  • Supports both 2D and 3D data with arbitrary channel definitions
  • Works with multiple image formats and runs end to end from preprocessing to inference
  • Offers multiple U-Net configurations: 2d, 3d_fullres, 3d_lowres, and 3d_cascade_fullres
  • Includes tools to find the best configuration, ensemble predictions, and apply postprocessing

Getting started

Install nnU-Net, set its three data path variables, then plan, train, and predict from the command line.

Install nnU-Net

Install the v2 package with pip.

bashbash
pip install nnunetv2

Set the data path variables

nnU-Net reads three environment variables that point to your raw data, preprocessed data, and results folders.

bashbash
export nnUNet_raw="/path/to/nnUNet_raw"
export nnUNet_preprocessed="/path/to/nnUNet_preprocessed"
export nnUNet_results="/path/to/nnUNet_results"

Plan and preprocess a dataset

Analyze the dataset and prepare it for training. The integrity check helps catch problems before training starts.

bashbash
nnUNetv2_plan_and_preprocess -d DATASET_ID --verify_dataset_integrity

Train a model

Train a configuration on a fold. Configuration is one of 2d, 3d_fullres, 3d_lowres, or 3d_cascade_fullres, and FOLD is a value from 0 to 4.

bashbash
nnUNetv2_train DATASET_NAME_OR_ID UNET_CONFIGURATION FOLD

Run inference on new images

Predict segmentations for a folder of input images using a trained configuration.

bashbash
nnUNetv2_predict -i INPUT_FOLDER -o OUTPUT_FOLDER -d DATASET_NAME_OR_ID -c CONFIGURATION

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Segment organs, lesions, or other structures in 2D or 3D biomedical scans
  • Train a segmentation model from scratch on a new dataset without manual pipeline tuning
  • Compare 2d, 3d_fullres, 3d_lowres, and 3d_cascade_fullres configurations and pick the best one
  • Ensemble multiple models and apply postprocessing to produce final segmentations

How nnU-Net compares

nnU-Net alongside other open-source medical imaging tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
nnU-Net★ 8.7kSelf-configuring deep learning for biomedical image segmentation
MONAI★ 8.4kPyTorch-based open-source framework for deep learning in healthcare imaging, from domain-specific data loaders to pretrained model zoos.
MedSAM★ 4.3kSegment Anything foundation model adapted for promptable segmentation across diverse medical imaging modalities.
TotalSegmentator★ 2.9kTool for robust automatic segmentation of over 100 anatomical structures in CT and MR images.
NeuroVFM★ 46Neuroimaging visual foundation model trained on 5.24M clinical MRI/CT volumes via self-supervised Vol-JEPA, covering 156 diagnostic tasks across both modalities.