Skip to content

no postprocessing.pkl #2789

Closed
Closed

Description

@buptxlsk

After I execute the

  1. nnUNetv2_predict -d Dataset004_Hippocampus -i ./nnUNet_raw/Dataset004_Hippocampus/imagesTs -o hippocampus_2d_predict -f 0 1 2 -tr nnUNetTrainer -c 2d -p nnUNetPlans --save_probabilities
  2. nnUNetv2_predict -d Dataset004_Hippocampus -i ./nnUNet_raw/Dataset004_Hippocampus/imagesTs -o hippocampus_3d_fullres_predict -f 0 1 2 -tr nnUNetTrainer -c 3d_fullres -p nnUNetPlans --save_probabilities
  3. nnUNetv2_ensemble -i hippocampus_2d_predict hippocampus_3d_fullres_predict -o hippocampus_ensemble -np 8

A postprocessing.pkl was not generated in ./nnUNet_results/Dataset004_Hippocampus/ensembles/ensemble___nnUNetTrainer__nnUNetPlans__2d___nnUNetTrainer__nnUNetPlans__3d_fullres___0_1_2/
so I can't execute nnUNetv2_apply_postprocessing , what should I do?
THANKS

Activity

  1. yulinnauu commented on Jun 12, 2025

    @yulinnauu

    Have you figured it out? meet with the same problem

  2. mrokuss commented on Apr 13, 2026

    @mrokuss
    Contributor

    Let's ask @claude if he can help!

  3. github-actions commented on Apr 13, 2026

    @github-actions
    Contributor

    🤖 nnU-Net Assistant

    This is a workflow issue — nnUNetv2_ensemble on test-set predictions intentionally does not generate postprocessing.pkl. That file can only be created by nnUNetv2_determine_postprocessing, which requires ground-truth labels to evaluate whether removing all-but-largest components improves Dice scores.

    Root cause

    postprocessing.pkl is generated by determine_postprocessing(), which compares model output against reference segmentations. Your test set (imagesTs) has no labels, so this step cannot be run on test-set predictions directly.

    The intended workflow is:

    1. Determine postprocessing on cross-validation predictions (where GT labels exist)
    2. Apply the resulting postprocessing.pkl to test-set ensemble predictions

    Solution

    Step 1 — Re-run validation with .npz output (if not already done)

    If you trained without --npz, re-run validation for each fold:

    nnUNetv2_train Dataset004_Hippocampus 2d 0 --val --npz
    nnUNetv2_train Dataset004_Hippocampus 2d 1 --val --npz
    nnUNetv2_train Dataset004_Hippocampus 2d 2 --val --npz
    nnUNetv2_train Dataset004_Hippocampus 3d_fullres 0 --val --npz
    nnUNetv2_train Dataset004_Hippocampus 3d_fullres 1 --val --npz
    nnUNetv2_train Dataset004_Hippocampus 3d_fullres 2 --val --npz

    Step 2 — Run nnUNetv2_find_best_configuration

    nnUNetv2_find_best_configuration Dataset004_Hippocampus -c 2d 3d_fullres -f 0 1 2

    This command will:

    • Ensemble the cross-validation predictions
    • Determine postprocessing automatically
    • Generate postprocessing.pkl at:
      $nnUNet_results/Dataset004_Hippocampus/ensembles/ensemble___nnUNetTrainer__nnUNetPlans__2d___nnUNetTrainer__nnUNetPlans__3d_fullres___0_1_2/postprocessing.pkl
    • Print the exact inference commands to use (saved to inference_instructions.txt)

    Step 3 — Apply postprocessing to your test ensemble

    nnUNetv2_apply_postprocessing \
      -i hippocampus_ensemble \
      -o hippocampus_ensemble_pp \
      -pp_pkl_file $nnUNet_results/Dataset004_Hippocampus/ensembles/ensemble___nnUNetTrainer__nnUNetPlans__2d___nnUNetTrainer__nnUNetPlans__3d_fullres___0_1_2/postprocessing.pkl \
      -plans_json $nnUNet_results/Dataset004_Hippocampus/nnUNetTrainer__nnUNetPlans__2d/plans.json \
      -dataset_json $nnUNet_results/Dataset004_Hippocampus/nnUNetTrainer__nnUNetPlans__2d/dataset.json

    Note: -plans_json and -dataset_json are required for ensemble output folders because nnUNetv2_ensemble does not copy a plans.json into the output folder (only dataset.json is copied — see ensemble.py#L96).

    References

  4. mrokuss commented on Nov 20, 2026

    @mrokuss
    Contributor

    Closing due to inactivity, feel free to reopen :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

questionUser asking for help or guidance

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions