Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot locate class or function path: 'RetinaNetDetector'. #8014

Closed
KumoLiu opened this issue Aug 13, 2024 · 0 comments · Fixed by #8015
Closed

Cannot locate class or function path: 'RetinaNetDetector'. #8014

KumoLiu opened this issue Aug 13, 2024 · 0 comments · Fixed by #8015

Comments

@KumoLiu
Copy link
Contributor

KumoLiu commented Aug 13, 2024

Describe the bug

{
	"name": "ModuleNotFoundError",
	"message": "Cannot locate class or function path: 'RetinaNetDetector'.",
	"stack": "---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 8
      5 bundle_config = ConfigParser()
      6 bundle_config.read_config(config)
----> 8 a = bundle_config.get_parsed_content(\"detector\", instantiate=True)

File /workspace/Code/MONAI/monai/bundle/config_parser.py:290, in ConfigParser.get_parsed_content(self, id, **kwargs)
    288 elif not kwargs.get(\"lazy\", True):
    289     self.parse(reset=not kwargs.get(\"lazy\", True))
--> 290 return self.ref_resolver.get_resolved_content(id=id, **kwargs)

File /workspace/Code/MONAI/monai/bundle/reference_resolver.py:193, in ReferenceResolver.get_resolved_content(self, id, **kwargs)
    181 def get_resolved_content(self, id: str, **kwargs: Any) -> ConfigExpression | str | Any | None:
    182     \"\"\"
    183     Get the resolved ``ConfigItem`` by id.
    184 
   (...)
    191 
    192     \"\"\"
--> 193     return self._resolve_one_item(id=id, **kwargs)

File /workspace/Code/MONAI/monai/bundle/reference_resolver.py:171, in ReferenceResolver._resolve_one_item(self, id, waiting_list, **kwargs)
    169 # save the resolved result into `resolved_content` to recursively resolve others
    170 if isinstance(item, ConfigComponent):
--> 171     self.resolved_content[id] = item.instantiate() if kwargs.get(\"instantiate\", True) else item
    172 elif isinstance(item, ConfigExpression):
    173     run_eval = kwargs.get(\"eval_expr\", True)

File /workspace/Code/MONAI/monai/bundle/config_item.py:298, in ConfigComponent.instantiate(self, **kwargs)
    296 args = self.resolve_args()
    297 args.update(kwargs)
--> 298 return instantiate(modname, mode, **args)

File /workspace/Code/MONAI/monai/utils/module.py:261, in instantiate(__path, __mode, **kwargs)
    259 print('*****', component, '*****')
    260 if component is None:
--> 261     raise ModuleNotFoundError(f\"Cannot locate class or function path: '{__path}'.\")
    262 m = look_up_option(__mode, CompInitMode)
    263 try:

ModuleNotFoundError: Cannot locate class or function path: 'RetinaNetDetector'."
}

To Reproduce

from monai.bundle import ConfigParser

!python -m monai.bundle download lung_nodule_ct_detection --bundle_dir "/workspace/Code/tutorials"
config = "/workspace/Code/tutorials/lung_nodule_ct_detection/configs/train.json"

bundle_config = ConfigParser()
bundle_config.read_config(config)

detector = bundle_config.get_parsed_content("detector", instantiate=True)
KumoLiu added a commit to KumoLiu/MONAI that referenced this issue Aug 13, 2024
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
rcremese pushed a commit to rcremese/MONAI that referenced this issue Sep 2, 2024
Fixes Project-MONAI#8014


### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant