nnUNet Segmentation Runner
Overview
Inspect what is deployed, choose the right nnUNet task, and run or prepare inference. Do not claim inference succeeded unless it was actually run and outputs were produced.
Prerequisites
- An nnUNet v2 environment is available.
nnUNet_results is configured. nnUNet_raw and nnUNet_preprocessed may also be needed.
- To actually run inference, the nnUNet CLI or Python API must be installed and usable.
- Custom trainers must be importable in the target environment.
Workflow
Inspect the nnUNet environment first.
- Prefer
nnUNet_results.
- Use
RESULTS_FOLDER only as a legacy fallback.
- If the environment is unclear, run
scripts/nnunetv2-doctor.sh first.
- Run
scripts/list_nnunet_results.py --json to enumerate real datasets, model folders, modalities, labels, folds, and checkpoints.
Parse the request into:
- modality
- target
- qualifiers such as left/right, tumor/cyst, whole organ vs substructure
Read metadata in this order:
dataset.json under nnUNet result folders for what is actually available
dataset/*.json in this repo for supplemental routing metadata
dataset/README.md only when adding or fixing dataset entries
Filter by modality, then match labels conservatively.
- Preserve laterality and substructure specificity.
- Keep tumor, cyst, lesion, vessel, and organ concepts separate.
- Treat repo metadata as secondary when it disagrees with deployed nnUNet results.
Choose how to run inference.
- Prefer
inference_instructions.txt when it exists.
- For default model folders, use
nnUNetv2_predict, plus ensembling or postprocessing if needed.
- For custom trainers, prefer exact model-folder inference through the Python predictor API.
- Use all available trained folds by default unless the environment only supports a specific fold such as
all.
- Keep input naming and file endings consistent with the selected task
dataset.json.
Return either:
- a compact dataset-to-label mapping
- or the selected task plus the exact inference command
{
"DatasetNameA": [1, 2],
"DatasetNameB": [7]
}
Return {} if no suitable modality or label is available, and say why.
Rules
- Prefer real nnUNet availability over paper claims or static repo metadata.
- If a dataset exists in repo metadata but not in
nnUNet_results, describe it as known but not deployed.
- Group multiple trainer folders under one dataset unless the user explicitly asks about checkpoints or trainer variants.
- Prefer officially generated
inference_instructions.txt when present.
- If input files do not match the trained task modality, naming scheme, or file ending, stop and say the input is not ready.
- Do not silently guess a configuration when multiple materially different deployed options exist.
- If repo metadata and nnUNet metadata disagree, report the mismatch explicitly.
- Do not guess custom trainer or plans settings from memory; read them from the selected model folder.
Extending Coverage
When adding or updating routing metadata:
- Follow
dataset/README.md.
- Keep names explicit, such as
kidney_left.
- Do not invent deployed availability if no trained output exists in
nnUNet_results.
References
- Read
references/nnunetv2.md only when you need the official nnUNet v2 path conventions, result layout, prediction commands, or dataset.json details.
- Read
references/examples.md only when you need compact routing or inference examples.
1---2name: medsegagent-nnunet-runner3description: Inspect `nnUNet_results`, choose a deployed nnUNet task, and run or prepare segmentation inference. Use when a user wants to match a free-form target to deployed labels, select the right task, or run prediction and postprocessing.4---56# nnUNet Segmentation Runner78## Overview910Inspect what is deployed, choose the right nnUNet task, and run or prepare inference. Do not claim inference succeeded unless it was actually run and outputs were produced.1112## Prerequisites1314- An nnUNet v2 environment is available.15- `nnUNet_results` is configured. `nnUNet_raw` and `nnUNet_preprocessed` may also be needed.16- To actually run inference, the nnUNet CLI or Python API must be installed and usable.17- Custom trainers must be importable in the target environment.1819## Workflow20211. Inspect the nnUNet environment first.22 - Prefer `nnUNet_results`.23 - Use `RESULTS_FOLDER` only as a legacy fallback.24 - If the environment is unclear, run `scripts/nnunetv2-doctor.sh` first.25 - Run `scripts/list_nnunet_results.py --json` to enumerate real datasets, model folders, modalities, labels, folds, and checkpoints.26272. Parse the request into:28 - modality29 - target30 - qualifiers such as left/right, tumor/cyst, whole organ vs substructure31323. Read metadata in this order:33 - `dataset.json` under nnUNet result folders for what is actually available34 - `dataset/*.json` in this repo for supplemental routing metadata35 - `dataset/README.md` only when adding or fixing dataset entries36374. Filter by modality, then match labels conservatively.38 - Preserve laterality and substructure specificity.39 - Keep tumor, cyst, lesion, vessel, and organ concepts separate.40 - Treat repo metadata as secondary when it disagrees with deployed nnUNet results.41425. Choose how to run inference.43 - Prefer `inference_instructions.txt` when it exists.44 - For default model folders, use `nnUNetv2_predict`, plus ensembling or postprocessing if needed.45 - For custom trainers, prefer exact model-folder inference through the Python predictor API.46 - Use all available trained folds by default unless the environment only supports a specific fold such as `all`.47 - Keep input naming and file endings consistent with the selected task `dataset.json`.48496. Return either:50 - a compact dataset-to-label mapping51 - or the selected task plus the exact inference command5253```json54{55 "DatasetNameA": [1, 2],56 "DatasetNameB": [7]57}58```5960Return `{}` if no suitable modality or label is available, and say why.6162## Rules6364- Prefer real nnUNet availability over paper claims or static repo metadata.65- If a dataset exists in repo metadata but not in `nnUNet_results`, describe it as known but not deployed.66- Group multiple trainer folders under one dataset unless the user explicitly asks about checkpoints or trainer variants.67- Prefer officially generated `inference_instructions.txt` when present.68- If input files do not match the trained task modality, naming scheme, or file ending, stop and say the input is not ready.69- Do not silently guess a configuration when multiple materially different deployed options exist.70- If repo metadata and nnUNet metadata disagree, report the mismatch explicitly.71- Do not guess custom trainer or plans settings from memory; read them from the selected model folder.7273## Extending Coverage7475When adding or updating routing metadata:76771. Follow `dataset/README.md`.782. Keep names explicit, such as `kidney_left`.793. Do not invent deployed availability if no trained output exists in `nnUNet_results`.8081## References8283- Read `references/nnunetv2.md` only when you need the official nnUNet v2 path conventions, result layout, prediction commands, or `dataset.json` details.84- Read `references/examples.md` only when you need compact routing or inference examples.