Closed lemuelatQSA closed 1 year ago
Hi @lemuelatQSA , according to the error message:
ModuleNotFoundError: Cannot locate class or function path: 'scripts.networks.unest_base_patch_4.UNesT'.
could you refer to the readme and export the pythonpath, and then retry the code?
export PYTHONPATH=$PYTHONPATH: '<path to the bundle root dir>/scripts'
Hi @yiheng-wang-nv and thank you for the prompt response.
The error persists after adding the scripts folder to the python path:
export PYTHONPATH=$PYTHONPATH:/data/projects/brain-segmentation-monai/models/wholeBrainSeg_Large_UNEST_segmentation/scripts; python app.py
Output:
/home/charlemgn/anaconda3/envs/monai/lib/python3.9/site-packages/monai/utils/deprecate_utils.py:321: FutureWarning: monai.transforms.io.dictionary LoadImaged.__init__:image_only: Current default value of argument `image_only=False` has been deprecated since version 1.1. It will be changed to `image_only=True` in version 1.3.
warn_deprecated(argname, msg, warning_category)
Traceback (most recent call last):
File "/home/charlemgn/anaconda3/envs/monai/lib/python3.9/site-packages/monai/bundle/config_item.py", line 292, in instantiate
return instantiate(modname, mode, **args)
File "/home/charlemgn/anaconda3/envs/monai/lib/python3.9/site-packages/monai/utils/module.py", line 247, in instantiate
raise ModuleNotFoundError(f"Cannot locate class or function path: '{__path}'.")
ModuleNotFoundError: Cannot locate class or function path: 'scripts.networks.unest_base_patch_4.UNesT'.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/data/Progetti/brain-segmentation-monai/test1.py", line 19, in <module>
model = model_config.get_parsed_content('network') # error here!
File "/home/charlemgn/anaconda3/envs/monai/lib/python3.9/site-packages/monai/bundle/config_parser.py", line 291, in get_parsed_content
return self.ref_resolver.get_resolved_content(id=id, **kwargs)
File "/home/charlemgn/anaconda3/envs/monai/lib/python3.9/site-packages/monai/bundle/reference_resolver.py", line 190, in get_resolved_content
return self._resolve_one_item(id=id, **kwargs)
File "/home/charlemgn/anaconda3/envs/monai/lib/python3.9/site-packages/monai/bundle/reference_resolver.py", line 160, in _resolve_one_item
self._resolve_one_item(id=d, waiting_list=waiting_list, **kwargs)
File "/home/charlemgn/anaconda3/envs/monai/lib/python3.9/site-packages/monai/bundle/reference_resolver.py", line 168, in _resolve_one_item
self.resolved_content[id] = item.instantiate() if kwargs.get("instantiate", True) else item
File "/home/charlemgn/anaconda3/envs/monai/lib/python3.9/site-packages/monai/bundle/config_item.py", line 294, in instantiate
raise RuntimeError(f"Failed to instantiate {self}.") from e
RuntimeError: Failed to instantiate {'_target_': 'scripts.networks.unest_base_patch_4.UNesT', 'in_channels': 1, 'out_channels': 133, 'patch_size': 4, 'depths': [2, 2, 8], 'embed_dim': [128, 256, 512], 'num_heads': [4, 8, 16]}.
Hi @lemuelatQSA , can you try:
export PYTHONPATH=$PYTHONPATH:/data/projects/brain-segmentation-monai/models/wholeBrainSeg_Large_UNEST_segmentation; python app.py
Hi @tangy5 , I think the readme has a mistake, in the bundle config it uses scripts.
, thus the python path should not include scripts
, could you please help to double confirm it and fix the issue of this bundle if needed? Thanks in advance!
Thank you @yiheng-wang-nv, removing scripts
made it work :)
Describe the bug
Model
wholeBrainSeg_Large_UNEST_segmentation
fails to be instantiated.Reporting the error below:
To Reproduce
Code:
Expected behavior
To instantiate the model correctly.
Environment