# mic-dkfz/nnunet architecture

> Architecture diagram of the GitHub repository mic-dkfz/nnunet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mic-dkfz/nnunet
- Repository: https://github.com/mic-dkfz/nnunet

## Overview

nnU-Net is a self-configuring biomedical image-segmentation framework. Its principal workflow prepares dataset inputs, fingerprints and plans for each dataset, preprocesses data, trains and selects models, then runs inference and evaluates predictions. The graph also preserves dataset conversion, model sharing, ensembling, and postprocessing as distinct capabilities. Relationships use README workflow statements and SOURCE INDEX references; unsampled implementation details are not asserted.

Main entry points: [`nnunetv2/inference/predict_from_raw_data.py`](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/inference/predict_from_raw_data.py) (Inference engine), [`nnunetv2/training/nnUNetTrainer/nnUNetTrainer.py`](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/training/nnUNetTrainer/nnUNetTrainer.py) (Trainer), [`nnunetv2/utilities/plans_handling/plans_handler.py`](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/utilities/plans_handling/plans_handler.py) (Plan manager), [`nnunetv2/dataset_conversion`](https://github.com/mic-dkfz/nnunet/tree/master/nnunetv2/dataset_conversion) (Dataset conversion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prepare["Dataset preparation"]
  node_conversion["Dataset conversion"]
  node_dataset_meta["Dataset metadata"]
end

subgraph group_configure["Planning and preprocessing"]
  node_fingerprint["Dataset fingerprint"]
  node_planner["Experiment planner"]
  node_plans["Plan manager<br/>[plans_handler.py]"]
  node_preprocessor["Preprocessing"]
  node_imageio["Image readers"]
end

subgraph group_train["Model training"]
  node_training_entry["Training entry point<br/>[run_training.py]"]
  node_dataset_loader["Training dataset<br/>[nnunet_dataset.py]"]
  node_trainer["Trainer<br/>[nnUNetTrainer.py]"]
  node_checkpoint["Checkpoint handling<br/>[checkpoints.py]"]
end

subgraph group_predict["Prediction and evaluation"]
  node_inference["Inference engine"]
  node_iterator["Inference input<br/>[data_iterators.py]"]
  node_export["Prediction export"]
  node_evaluation["Prediction evaluation"]
  node_model_selection["Model selection"]
end

subgraph group_models["Model utilities"]
  node_ensemble["Ensembling<br/>[ensemble.py]"]
  node_postprocessing["Postprocessing"]
  node_sharing["Model sharing"]
  node_paths["Data locations<br/>[paths.py]"]
end

node_user(("Researcher"))

node_user -->|"prepares data"| node_conversion
node_conversion -.->|"defines dataset"| node_dataset_meta
node_dataset_meta -.->|"describes inputs"| node_fingerprint
node_fingerprint -->|"informs planning"| node_planner
node_planner -->|"creates plans"| node_plans
node_plans -->|"configures preprocessing"| node_preprocessor
node_preprocessor -.->|"reads images"| node_imageio
node_user -->|"starts training"| node_training_entry
node_training_entry -->|"runs trainer"| node_trainer
node_trainer -->|"loads dataset"| node_dataset_loader
node_trainer -.->|"saves checkpoints"| node_checkpoint
node_user -->|"requests inference"| node_inference
node_inference -->|"loads inputs"| node_iterator
node_inference -->|"exports predictions"| node_export
node_user -.->|"evaluates results"| node_evaluation
node_evaluation -.->|"supports selection"| node_model_selection
node_inference -->|"loads weights"| node_checkpoint
node_inference -->|"reads plans"| node_plans
node_user -.->|"combines models"| node_ensemble
node_user -.->|"refines predictions"| node_postprocessing
node_user -.->|"shares models"| node_sharing

click node_conversion "https://github.com/mic-dkfz/nnunet/tree/master/nnunetv2/dataset_conversion"
click node_dataset_meta "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/dataset_conversion/generate_dataset_json.py"
click node_fingerprint "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/experiment_planning/dataset_fingerprint/fingerprint_extractor.py"
click node_planner "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/experiment_planning/experiment_planners/default_experiment_planner.py"
click node_plans "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/utilities/plans_handling/plans_handler.py"
click node_preprocessor "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/preprocessing/preprocessors/default_preprocessor.py"
click node_imageio "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/imageio/base_reader_writer.py"
click node_training_entry "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/run/run_training.py"
click node_dataset_loader "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/training/dataloading/nnunet_dataset.py"
click node_trainer "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/training/nnUNetTrainer/nnUNetTrainer.py"
click node_checkpoint "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/utilities/checkpoints.py"
click node_inference "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/inference/predict_from_raw_data.py"
click node_iterator "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/inference/data_iterators.py"
click node_export "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/inference/export_prediction.py"
click node_evaluation "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/evaluation/evaluate_predictions.py"
click node_model_selection "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/evaluation/find_best_configuration.py"
click node_ensemble "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/ensembling/ensemble.py"
click node_postprocessing "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/postprocessing/remove_connected_components.py"
click node_sharing "https://github.com/mic-dkfz/nnunet/tree/master/nnunetv2/model_sharing"
click node_paths "https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/paths.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_conversion,node_dataset_meta toneBlue
class node_fingerprint,node_planner,node_plans,node_preprocessor,node_imageio toneAmber
class node_training_entry,node_dataset_loader,node_trainer,node_checkpoint toneMint
class node_inference,node_iterator,node_export,node_evaluation,node_model_selection toneRose
class node_ensemble,node_postprocessing,node_sharing,node_paths,node_user toneIndigo
```

## Components

### Dataset preparation

- [Dataset conversion](https://github.com/mic-dkfz/nnunet/tree/master/nnunetv2/dataset_conversion): `nnunetv2/dataset_conversion`
- [Dataset metadata](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/dataset_conversion/generate_dataset_json.py): `nnunetv2/dataset_conversion/generate_dataset_json.py`

### Planning and preprocessing

- [Dataset fingerprint](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/experiment_planning/dataset_fingerprint/fingerprint_extractor.py): `nnunetv2/experiment_planning/dataset_fingerprint/fingerprint_extractor.py`
- [Experiment planner](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/experiment_planning/experiment_planners/default_experiment_planner.py): `nnunetv2/experiment_planning/experiment_planners/default_experiment_planner.py`
- [Plan manager](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/utilities/plans_handling/plans_handler.py): `nnunetv2/utilities/plans_handling/plans_handler.py`
- [Preprocessing](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/preprocessing/preprocessors/default_preprocessor.py): `nnunetv2/preprocessing/preprocessors/default_preprocessor.py`
- [Image readers](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/imageio/base_reader_writer.py): `nnunetv2/imageio/base_reader_writer.py`

### Model training

- [Training entry point](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/run/run_training.py): `nnunetv2/run/run_training.py`
- [Training dataset](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/training/dataloading/nnunet_dataset.py): `nnunetv2/training/dataloading/nnunet_dataset.py`
- [Trainer](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/training/nnUNetTrainer/nnUNetTrainer.py): `nnunetv2/training/nnUNetTrainer/nnUNetTrainer.py`
- [Checkpoint handling](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/utilities/checkpoints.py): `nnunetv2/utilities/checkpoints.py`

### Prediction and evaluation

- [Inference engine](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/inference/predict_from_raw_data.py): `nnunetv2/inference/predict_from_raw_data.py`
- [Inference input](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/inference/data_iterators.py): `nnunetv2/inference/data_iterators.py`
- [Prediction export](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/inference/export_prediction.py): `nnunetv2/inference/export_prediction.py`
- [Prediction evaluation](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/evaluation/evaluate_predictions.py): `nnunetv2/evaluation/evaluate_predictions.py`
- [Model selection](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/evaluation/find_best_configuration.py): `nnunetv2/evaluation/find_best_configuration.py`

### Model utilities

- [Ensembling](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/ensembling/ensemble.py): `nnunetv2/ensembling/ensemble.py`
- [Postprocessing](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/postprocessing/remove_connected_components.py): `nnunetv2/postprocessing/remove_connected_components.py`
- [Model sharing](https://github.com/mic-dkfz/nnunet/tree/master/nnunetv2/model_sharing): `nnunetv2/model_sharing`
- [Data locations](https://github.com/mic-dkfz/nnunet/blob/master/nnunetv2/paths.py): `nnunetv2/paths.py`

### Other components

- **Researcher**

## Connections

- Researcher → Dataset conversion: prepares data
- Dataset conversion → Dataset metadata: defines dataset
- Dataset metadata → Dataset fingerprint: describes inputs
- Dataset fingerprint → Experiment planner: informs planning (evidence: `nnunetv2/experiment_planning/experiment_planners/default_experiment_planner.py`)
- Experiment planner → Plan manager: creates plans (evidence: `nnunetv2/experiment_planning/experiment_planners/default_experiment_planner.py`)
- Plan manager → Preprocessing: configures preprocessing (evidence: `nnunetv2/preprocessing/preprocessors/default_preprocessor.py`)
- Preprocessing → Image readers: reads images
- Researcher → Training entry point: starts training
- Training entry point → Trainer: runs trainer (evidence: `nnunetv2/run/run_training.py`)
- Trainer → Training dataset: loads dataset (evidence: `nnunetv2/training/nnUNetTrainer/nnUNetTrainer.py`)
- Trainer → Checkpoint handling: saves checkpoints (evidence: `nnunetv2/training/nnUNetTrainer/nnUNetTrainer.py`)
- Researcher → Inference engine: requests inference
- Inference engine → Inference input: loads inputs (evidence: `nnunetv2/inference/predict_from_raw_data.py`)
- Inference engine → Prediction export: exports predictions (evidence: `nnunetv2/inference/predict_from_raw_data.py`)
- Researcher → Prediction evaluation: evaluates results
- Prediction evaluation → Model selection: supports selection
- Inference engine → Checkpoint handling: loads weights (evidence: `nnunetv2/inference/predict_from_raw_data.py`)
- Inference engine → Plan manager: reads plans (evidence: `nnunetv2/inference/predict_from_raw_data.py`)
- Researcher → Ensembling: combines models
- Researcher → Postprocessing: refines predictions
- Researcher → Model sharing: shares models
