This guide covers prediction, optional ensembling, and postprocessing.
Input images must match the trained dataset's naming convention and file endings. See:
If you previously ran nnUNetv2_find_best_configuration, use the commands it generated in inference_instructions.txt whenever possible.
nnUNetv2_predict -i INPUT_FOLDER -o OUTPUT_FOLDER -d DATASET_NAME_OR_ID -c CONFIGURATIONIf you want to ensemble probability outputs from multiple configurations, add --save_probabilities:
nnUNetv2_predict -i INPUT_FOLDER -o OUTPUT_FOLDER -d DATASET_NAME_OR_ID -c CONFIGURATION --save_probabilitiesBy default, inference uses the 5 trained folds as an ensemble. If you trained the all fold and want to use only that model:
nnUNetv2_predict -i INPUT_FOLDER -o OUTPUT_FOLDER -d DATASET_NAME_OR_ID -c CONFIGURATION -f allnnUNetv2_ensemble -i FOLDER1 FOLDER2 -o OUTPUT_FOLDER -np NUM_PROCESSESThe input folders must contain probability files produced with --save_probabilities.
nnUNetv2_apply_postprocessing \
-i FOLDER_WITH_PREDICTIONS \
-o OUTPUT_FOLDER \
--pp_pkl_file POSTPROCESSING_FILE \
-plans_json PLANS_FILE \
-dataset_json DATASET_JSON_FILEFor single-configuration predictions, plans.json and dataset.json are usually copied automatically. For ensemble outputs, provide them explicitly.
If you want to run inference directly from an exported or copied model folder:
nnUNetv2_predict_from_modelfolder -i INPUT_FOLDER -o OUTPUT_FOLDER -m MODEL_FOLDERTo move a trained model to another machine:
- Export it:
nnUNetv2_export_model_to_zip -d DATASET_NAME_OR_ID -o MODEL.zip- Install it on the target machine:
nnUNetv2_install_pretrained_model_from_zip MODEL.zipThe target machine still needs a compatible nnU-Net installation and all dependencies.
If the model was trained with a custom nnUNetTrainer subclass, the target machine also
needs that trainer class to be importable. See:
The old page on pretrained-model inference remains here:
Check that page for the current status before relying on it.