MIC-DKFZ / nnUNet

Apache License 2.0
5.57k stars 1.7k forks source link

Error Code when Running Inference in version 1 #2335

Open thahmadalm opened 2 months ago

thahmadalm commented 2 months ago

I get the following error when running inference and can't fix it:

using model stored in /content/results/nnUNet/2d/Task106_MiniLung/nnUNetTrainerV2__nnUNetPlansv2.1 This model expects 1 input modalities for each image Found 5 unique case ids, here are some examples: ['lung_095' 'lung_096' 'lung_095' 'lung_093' 'lung_095'] If they don't look right, make sure to double check your filenames. They must end with _0000.nii.gz etc number of cases: 5 number of cases that still need to be predicted: 5 emptying cuda cache loading parameters for folds, None folds is None so we will automatically look for output folders (not using 'all'!) found the following folds: ['/content/results/nnUNet/2d/Task106_MiniLung/nnUNetTrainerV2nnUNetPlansv2.1/fold_0'] Traceback (most recent call last): File "/usr/local/bin/nnUNet_predict", line 8, in sys.exit(main()) File "/usr/local/lib/python3.10/dist-packages/nnunet/inference/predict_simple.py", line 219, in main predict_from_folder(model_folder_name, input_folder, output_folder, folds, save_npz, num_threads_preprocessing, File "/usr/local/lib/python3.10/dist-packages/nnunet/inference/predict.py", line 658, in predict_from_folder return predict_cases(model, list_of_lists[part_id::num_parts], output_files[part_id::num_parts], folds, File "/usr/local/lib/python3.10/dist-packages/nnunet/inference/predict.py", line 184, in predict_cases trainer, params = load_model_and_checkpoint_files(model, folds, mixed_precision=mixed_precision, File "/usr/local/lib/python3.10/dist-packages/nnunet/training/model_restore.py", line 140, in load_model_and_checkpoint_files trainer = restore_model(join(folds[0], "%s.model.pkl" % checkpoint_name), fp16=mixed_precision) File "/usr/local/lib/python3.10/dist-packages/nnunet/training/model_restore.py", line 56, in restore_model info = load_pickle(pkl_file) File "/usr/local/lib/python3.10/dist-packages/batchgenerators/utilities/file_and_folder_operations.py", line 57, in load_pickle with open(file, mode) as f: **FileNotFoundError: [Errno 2] No such file or directory: '/content/results/nnUNet/2d/Task106_MiniLung/nnUNetTrainerV2nnUNetPlansv2.1/fold_0/model_final_checkpoint.model.pkl'**

mrokuss commented 1 month ago

Hey @thahmadalm

nnUNet V1 is no longer supported - consider switching to V2 for a smooth running training. From the error it looks like the model can't load the checkpoint since the path '/content/results/nnUNet/2d/Task106_MiniLung/nnUNetTrainerV2__nnUNetPlansv2.1/fold_0/model_final_checkpoint.model.pkl' does not exist.