Skip to content

Commit

Permalink
add error message when trainer is not found in inference
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianIsensee committed Apr 26, 2024
1 parent 60b23b4 commit 5db9604
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion nnunetv2/inference/predict_from_raw_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def initialize_from_trained_model_folder(self, model_training_output_dir: str,
num_input_channels = determine_num_input_channels(plans_manager, configuration_manager, dataset_json)
trainer_class = recursive_find_python_class(join(nnunetv2.__path__[0], "training", "nnUNetTrainer"),
trainer_name, 'nnunetv2.training.nnUNetTrainer')

if trainer_class is None:
raise RuntimeError(f'Unable to locate trainer class {trainer_name} in nnunetv2.training.nnUNetTrainer. '
f'Please place it there (in any .py file)!')
network = trainer_class.build_network_architecture(
configuration_manager.network_arch_class_name,
configuration_manager.network_arch_init_kwargs,
Expand Down
2 changes: 1 addition & 1 deletion nnunetv2/utilities/find_class_by_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def recursive_find_python_class(folder: str, class_name: str, current_module: st
tr = recursive_find_python_class(join(folder, modname), class_name, current_module=next_current_module)
if tr is not None:
break
return tr
return tr

0 comments on commit 5db9604

Please sign in to comment.