rixez / Brats21_KAIST_MRI_Lab

Codes and pretrained weights for winning submission of 2021 Brain Tumor Segmentation (BraTS) Challenge
Apache License 2.0
165 stars 21 forks source link

Checkpoint Loading Failed #24

Open GuangSTrip opened 1 month ago

GuangSTrip commented 1 month ago

I am trying to inference with command line. I have run nnUNet_predict -i <input_folder> -o <output_folder1> -t <TASK_ID> -m 3d_fullres -tr nnUNetTrainerV2BraTSRegions_DA4_BN_BD --save_npz successfully. However, there is something wrong with the second command nnUNet_predict -i <input_folder> -o <output_folder2> -t <TASK_ID> -m 3d_fullres -tr nnUNetTrainerV2BraTSRegions_DA4_BN_BD_largeUnet_Groupnorm --save_npz, though I have put the trained models in RESULTS_FOLDER correctly. I have no idea where the problem is TwT

Here is the output message below

folds is None so we will automatically look for output folders (not using 'all'!)
found the following folds:  ['/hy-tmp/Brats21_KAIST_MRI_Lab-main/datasets/nnUNet_trained_models/nnUNet/3d_fullres/Task500_BraTS/nnUNetTrainerV2BraTSRegions_DA4_BN_BD_largeUnet_Groupnorm__nnUNetPlansv2.1/fold_0', '/hy-tmp/Brats21_KAIST_MRI_Lab-main/datasets/nnUNet_trained_models/nnUNet/3d_fullres/Task500_BraTS/nnUNetTrainerV2BraTSRegions_DA4_BN_BD_largeUnet_Groupnorm__nnUNetPlansv2.1/fold_1', '/hy-tmp/Brats21_KAIST_MRI_Lab-main/datasets/nnUNet_trained_models/nnUNet/3d_fullres/Task500_BraTS/nnUNetTrainerV2BraTSRegions_DA4_BN_BD_largeUnet_Groupnorm__nnUNetPlansv2.1/fold_2', '/hy-tmp/Brats21_KAIST_MRI_Lab-main/datasets/nnUNet_trained_models/nnUNet/3d_fullres/Task500_BraTS/nnUNetTrainerV2BraTSRegions_DA4_BN_BD_largeUnet_Groupnorm__nnUNetPlansv2.1/fold_3', '/hy-tmp/Brats21_KAIST_MRI_Lab-main/datasets/nnUNet_trained_models/nnUNet/3d_fullres/Task500_BraTS/nnUNetTrainerV2BraTSRegions_DA4_BN_BD_largeUnet_Groupnorm__nnUNetPlansv2.1/fold_4']
------folds------
/hy-tmp/Brats21_KAIST_MRI_Lab-main/datasets/nnUNet_trained_models/nnUNet/3d_fullres/Task500_BraTS/nnUNetTrainerV2BraTSRegions_DA4_BN_BD_largeUnet_Groupnorm__nnUNetPlansv2.1/fold_0
------------
Traceback (most recent call last):
  File "/usr/local/bin/nnUNet_predict", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/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.8/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.8/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.8/dist-packages/nnunet/training/model_restore.py", line 141, 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.8/dist-packages/nnunet/training/model_restore.py", line 73, in restore_model
    raise RuntimeError("Could not find the model trainer specified in checkpoint in nnunet.trainig.network_training. If it "
RuntimeError: Could not find the model trainer specified in checkpoint in nnunet.trainig.network_training. If it is not located there, please move it or change the code of restore_model. Your model trainer can be located in any directory within nnunet.trainig.network_training (search is recursive).
Debug info: 
checkpoint file: None
Name of trainer: nnUNetTrainerV2BraTSRegions_DA4_BN_BD_largeUnet_Groupnorm
GuangSTrip commented 1 month ago

I have found the cause of this error. It is beacuse I didn't replace the nnUNet folder in python3.8/dist-package, where the origin nnUNet package do not have class nnUNetTrainerV2BraTSRegions_DA4_BN_BD_largeUnet.