nnunetv2
Use nnU-Net v2 for medical image segmentation workflows: dataset preparation, planning/preprocessing, training, inference/evaluation, model sharing, and customization.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- nnunetv2
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use nnU-Net v2 for medical image segmentation workflows: dataset preparation, planning/preprocessing, training, inference/evaluation, model sharing, and customization.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/cli-map.md4.3 KB
- 参考文档references/repo-provenance.md2.2 KB
- 参考文档references/repo-routing-metadata.json404 B
- 参考文档references/troubleshooting.md4.1 KB
- 参考文档references/workflow-overview.md4.2 KB
- 脚本scripts/check_nnunet_setup.py3.8 KB
03 SKILL.md 正文
nnU-Net v2
Use this skill when the user needs practical help with nnU-Net v2, the self-configuring medical image segmentation framework exposed by the nnunetv2 Python package and nnUNetv2_* command-line tools.
Quick Start
- Confirm the package and core commands are available:
python scripts/check_nnunet_setup.py --require-commands - Confirm the nnU-Net storage environment variables are set for the requested workflow:
nnUNet_raw,nnUNet_preprocessed, andnnUNet_results. - Route to the focused sub-skill before giving detailed commands; nnU-Net workflows are order-dependent.
- Prefer CLI commands for user workflows and use Python APIs for programmatic integration, dry-run command generation, or validation helpers.
Route by Task
- Dataset folders,
dataset.json, labels, regions, ignore labels, file endings, MSD/v1 conversion, or path variables: usesub-skills/data-preparation/SKILL.md. - Fingerprint extraction, experiment planning, preprocessing, plans files, residual encoder presets, or rerun decisions: use
sub-skills/planning-preprocessing/SKILL.md. - Training folds/configurations,
--npz, validation-only reruns, resume, checkpoints, device/DDP, pretrained weights, logging, or manual splits: usesub-skills/training-configuration/SKILL.md. - Prediction,
predict_from_modelfolder, ensembling, postprocessing, evaluation, best-configuration selection, model zip import/export/download, or inference troubleshooting: usesub-skills/inference-evaluation/SKILL.md. - Custom trainers, planners, preprocessors, normalization, image I/O, class discovery,
nnUNet_extTrainer, or custom-trainer model portability: usesub-skills/customization-extension/SKILL.md.
End-to-End Workflow
For a new dataset, the normal route is:
# 1) Prepare raw dataset in nnU-Net format.
python sub-skills/data-preparation/scripts/validate_dataset_json.py /path/to/nnUNet_raw/Dataset123_MyDataset --check-files
# 2) Plan and preprocess.
nnUNetv2_plan_and_preprocess -d 123 --verify_dataset_integrity
# 3) Train folds; use --npz if model selection/ensembling may be needed.
nnUNetv2_train 123 3d_fullres 0 --npz
# 4) Select/evaluate/predict after training artifacts exist.
nnUNetv2_find_best_configuration 123 -c 2d 3d_fullres
nnUNetv2_predict -i INPUT_FOLDER -o OUTPUT_FOLDER -d 123 -c 3d_fullres
Read references/workflow-overview.md for ordering, prerequisites, and cross-skill handoffs.
Core Commands
nnUNetv2_plan_and_preprocessruns dataset fingerprinting, experiment planning, and preprocessing together.nnUNetv2_extract_fingerprint,nnUNetv2_plan_experiment, andnnUNetv2_preprocessrun those stages separately.nnUNetv2_traintrains a dataset/configuration/fold, including validation and resume modes.nnUNetv2_predictpredicts from stored nnU-Net results;nnUNetv2_predict_from_modelfolderpredicts from an explicit model folder.nnUNetv2_find_best_configuration,nnUNetv2_ensemble,nnUNetv2_apply_postprocessing, and evaluation commands handle model selection and validation outputs.nnUNetv2_export_model_to_zip,nnUNetv2_install_pretrained_model_from_zip, andnnUNetv2_download_pretrained_model_by_urlmove model bundles.
Read references/cli-map.md for command ownership and when to inspect -h.
References and Helpers
references/repo-provenance.md: source version, evidence paths, and refresh baseline.references/workflow-overview.md: complete workflow order and handoffs between sub-skills.references/cli-map.md: command map, owning sub-skill, and safe verification approach.references/troubleshooting.md: cross-cutting install, path, dependency, GPU, and workflow-order failures.scripts/check_nnunet_setup.py: safe import, command, environment-variable, and optional Torch backend check.
Operating Rules
- Do not skip dataset validation; malformed
dataset.json, file endings, labels, or channel suffixes usually fail later during planning or prediction. - Use
--npzduring training if laternnUNetv2_find_best_configurationor probability ensembling may be needed; use--val --npzto recover validation probabilities for already-trained folds. - Treat training, preprocessing, full inference, benchmarks, and integration scripts as potentially expensive; use helper scripts here for checks and command generation, not for long runs.
- When a model uses a custom trainer, ensure the class is importable on every machine that will continue training or run inference.
- Keep generated commands generic; never rely on the original source checkout being present.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).