MIC-DKFZ / nnUNet

Apache License 2.0
5.9k stars 1.76k forks source link

assert folder_with_segs_from_prev_stage is not None, \ AssertionError: The requested configuration is a cascaded network. It requires the segmentations of the previous stage (3d_lowres) as input. Please provide the folder where they are located via folder_with_segs_from_prev_stage #1959

Closed linamedicalimaging closed 8 months ago

linamedicalimaging commented 9 months ago

Hi,

I was using nnUNetV2 and during the process of "Automatically determine the best configuration", I entered the command: nnUNetv2_find_best_configuration Dataset802_HepaticVessel -c 2d 3d_fullres 3d_lowres 3d_cascade_fullres and got the following results: All results: nnUNetTrainernnUNetPlans2d: 0.5962835872196462 nnUNetTrainernnUNetPlans3d_fullres: 0.5868312973033705 nnUNetTrainernnUNetPlans3d_lowres: 0.6349078614620299 nnUNetTrainernnUNetPlans3d_cascade_fullres: 0.6095863948014932 ensemblennUNetTrainernnUNetPlans2dnnUNetTrainernnUNetPlans3d_fullres_0_1_2_34: 0.6158162384358411 ensemblennUNetTrainernnUNetPlans2d_nnUNetTrainernnUNetPlans3d_lowres___0_1_2_34: 0.6328995874888456 ensemblennUNetTrainernnUNetPlans2d_nnUNetTrainernnUNetPlans3d_cascadefullres0_1_2_3_4: 0.632770315614815 ensemble_nnUNetTrainernnUNetPlans3d_fullres_nnUNetTrainernnUNetPlans3dlowres0_1_2_34: 0.6300093464010545 ensemblennUNetTrainernnUNetPlans3d_fullres_nnUNetTrainernnUNetPlans3d_cascadefullres0_1_2_3_4: 0.6208252427453589 ensemble_nnUNetTrainernnUNetPlans3d_lowres_nnUNetTrainernnUNetPlans__3d_cascadefullres0_1_2_3_4: 0.6380353304951599

Best: ensemble_nnUNetTrainernnUNetPlans3d_lowres_nnUNetTrainernnUNetPlans__3d_cascadefullres0_1_2_3_4: 0.6380353304951599

Determining postprocessing for best model/ensemble Removing all but the largest foreground region did not improve results! Removing all but the largest component for 1 did not improve results! Dice before: 0.63354 after: 0.5421 Removing all but the largest component for 2 did not improve results! Dice before: 0.64253 after: 0.61577

Run inference like this:

An ensemble won! What a surprise! Run the following commands to run predictions with the ensemble members:

nnUNetv2_predict -d Dataset802_HepaticVessel -i INPUT_FOLDER -o OUTPUT_FOLDER_MODEL_1 -f 0 1 2 3 4 -tr nnUNetTrainer -c 3d_lowres -p nnUNetPlans --save_probabilities nnUNetv2_predict -d Dataset802_HepaticVessel -i INPUT_FOLDER -o OUTPUT_FOLDER_MODEL_2 -f 0 1 2 3 4 -tr nnUNetTrainer -c 3d_cascade_fullres -p nnUNetPlans --save_probabilities

The run ensembling with:

nnUNetv2_ensemble -i OUTPUT_FOLDER_MODEL_1 OUTPUT_FOLDER_MODEL_2 -o OUTPUT_FOLDER -np 8

Once inference is completed, run postprocessing like this:

nnUNetv2_apply_postprocessing -i OUTPUT_FOLDER -o OUTPUT_FOLDER_PP -pp_pkl_file /home/lina/nnunet/nnUNet/DATASET/nnUNet_results/Dataset802_HepaticVessel/ensembles/ensemble_nnUNetTrainernnUNetPlans3d_lowres_nnUNetTrainernnUNetPlans__3d_cascadefullres0_1_2_3_4/postprocessing.pkl -np 8 -plans_json /home/lina/nnunet/nnUNet/DATASET/nnUNet_results/Dataset802_HepaticVessel/ensembles/ensemble_nnUNetTrainernnUNetPlans3d_lowres_nnUNetTrainernnUNetPlans__3d_cascadefullres0_1_2_3_4/plans.json

Then I entered the command: CUDA_VISIBLE_DEVICES=6 nnUNetv2_predict -d Dataset802_HepaticVessel -i /home/lina/nnunet/nnUNet/DATASET/nnUNet_raw/Dataset802_HepaticVessel/imagesTs -o /home/lina/nnunet/nnUNet/DATASET/nnUNet_prediction/imagesPre1 -f 0 1 2 3 4 -tr nnUNetTrainer -c 3d_lowres -p nnUNetPlans --save_probabilities

After that, I entered another command: CUDA_VISIBLE_DEVICES=6 nnUNetv2_predict -d Dataset802_HepaticVessel -i /home/lina/nnunet/nnUNet/DATASET/nnUNet_prediction/imagesPre1 -o /home/lina/nnunet/nnUNet/DATASET/nnUNet_prediction/imagesPre2 -f 0 1 2 3 4 -tr nnUNetTrainer -c 3d_cascade_fullres -p nnUNetPlans --save_probabilities

And encountered an error: AssertionError: The requested configuration is a cascaded network. It requires the segmentations of the previous stage (3d_lowres) as input. Please provide the folder where they are located via folder_with_segs_from_prev_stage

I changed the command but still encountered an error: CUDA_VISIBLE_DEVICES=6 nnUNetv2_predict -d Dataset802_HepaticVessel -i /home/lina/nnunet/nnUNet/DATASET/nnUNet_raw/Dataset802_HepaticVessel/imagesTs -o /home/lina/nnunet/nnUNet/DATASET/nnUNet_prediction/imagesPre2 -f 0 1 2 3 4 -tr nnUNetTrainer -c 3d_cascade_fullres -p nnUNetPlans --save_probabilities

I have already completed the prediction training for 3d_lowres. Where is the problem?

constantinulrich commented 8 months ago

Hi,

CUDA_VISIBLE_DEVICES=6 nnUNetv2_predict -d Dataset802_HepaticVessel -i /home/lina/nnunet/nnUNet/DATASET/nnUNet_raw/Dataset802_HepaticVessel/imagesTs -o /home/lina/nnunet/nnUNet/DATASET/nnUNet_prediction/imagesPre2 -f 0 1 2 3 4 -tr nnUNetTrainer -c 3d_cascade_fullres -p nnUNetPlans --save_probabilities

you need to give the path to the lowres prediction using the flag -prev_stage_predictions

linamedicalimaging commented 8 months ago

Dear FabianIsensee and constantinulrich,

I wanted to let you know that I was able to get the 3d_cascade_fullres model running properly after getting your helpful advice. : ) Passing the path to the 3d_lowres predictions using the -prev_stage_predictions flag was exactly what I needed to do.

Thank you so much for your quick response and guidance. I really appreciate you taking the time to explain what I was missing. Your project documentation is very thorough, but having that extra bit of help from the creator is invaluable.

Thank you very much again.

Kind regards, Lina

constantinulrich commented 8 months ago

Happy, that we could help! Best Constantin