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

Problems with Inference with existing models #116

Open
zhanzf opened this issue Aug 18, 2024 · 2 comments
Open

Problems with Inference with existing models #116

zhanzf opened this issue Aug 18, 2024 · 2 comments

Comments

@zhanzf
Copy link

zhanzf commented Aug 18, 2024

https://github.com/likyoo/open-cd/blob/main/docs/inference.md

When I try to test the inference with existing models, I encouter the following problems.
I want to know how to resovle this problem.
Thanks a lot.

(openmmlab) PS D:\***\open-cd> python
Python 3.8.19 (default, Mar 20 2024, 19:55:45) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from opencd.apis import OpenCDInferencer
>>> inferencer = OpenCDInferencer(model='changer_ex_r18_512x512_40k_levircd.py', weights='ChangerEx_r18-512x512_40k_levircd_20221223_120511.pth', classes=('unchanged', 'changed'), palette=[[0, 0, 0], [255, 255, 255]])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\***\open-cd\opencd\apis\opencd_inferencer.py", line 41, in __init__
    super().__init__(scope=scope, **kwargs)
  File "d:\***\mmsegmentation\mmseg\apis\mmseg_inferencer.py", line 81, in __init__
    super().__init__(
  File "D:\***\miniconda3\envs\openmmlab\lib\site-packages\mmengine\infer\infer.py", line 160, in __init__
    cfg, _weights = self._load_model_from_metafile(model)
  File "D:\***\miniconda3\envs\openmmlab\lib\site-packages\mmengine\infer\infer.py", line 374, in _load_model_from_metafile
    assert self.scope in MODULE2PACKAGE, (
AssertionError: opencd not in {'mmcls': 'mmcls', 'mmdet': 'mmdet', 'mmdet3d': 'mmdet3d', 'mmseg': 'mmsegmentation', 'mmaction': 'mmaction2', 'mmtrack': 'mmtrack', 'mmpose': 'mmpose', 'mmedit': 'mmedit', 'mmocr': 'mmocr', 'mmgen': 'mmgen', 'mmfewshot': 'mmfewshot', 'mmrazor': 'mmrazor', 'mmflow': 'mmflow', 'mmhuman3d': 'mmhuman3d', 'mmrotate': 'mmrotate', 'mmselfsup': 'mmselfsup', 'mmyolo': 'mmyolo', 'mmpretrain': 'mmpretrain', 'mmagic': 'mmagic'}!,please pass a valid scope.
>>>
@BarcelonaTong
Copy link

I had the same problem, is it solved now?

@zhanzf
Copy link
Author

zhanzf commented Oct 5, 2024

When @likyoo remind to confirm the path of model correct in #119 .
I do the following change to the second command as below:

# Load models into memory
inferencer = OpenCDInferencer(model='changer_r18_levir_workdir/changer_ex_r18_512x512_40k_levircd.py', weights='changer_r18_levir_workdir/best_mIoU_iter_40000.pth', classes=('unchanged', 'changed'), palette=[[0, 0, 0], [255, 255, 255]])

The model and weight path from the train below:

python tools/train.py configs/changer/changer_ex_r18_512x512_40k_levircd.py --work-dir ./changer_r18_levir_workdir

Then the above problem been solved.

@zhanzf zhanzf closed this as completed Oct 5, 2024
@zhanzf zhanzf reopened this Oct 5, 2024
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

No branches or pull requests

2 participants