Skip to content

Cyclic depedency causes KeyError: 'ConvWS is already registered in conv layer' #3249

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

Closed
namheegordonkim opened this issue Jul 8, 2020 · 3 comments

Comments

@namheegordonkim
Copy link

Thanks for your error report and we appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help. ✅
  2. The bug has not been fixed in the latest version. ✅

Describe the bug
Any script using import statements with mdet.apis raises KeyError in mmcv's registry.py, which safeguards against duplicate custom PyTorch modules from being registered. Essentially, ConvWS and ConvAWS modules are being registered more than once.

Reproduction

  1. What command or script did you run?
python demo/image_demo.py
  1. Did you make any modifications on the code or config? Did you understand what you have modified?
    No
  2. What dataset did you use?
    N/A

Environment

  1. Please run python mmdet/utils/collect_env.py to collect necessary environment infomation and paste it here.

Does not run due to error.

  1. You may add addition that may be helpful for locating the problem, such as
    • How you installed PyTorch [e.g., pip, conda, source]
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

Error traceback

Traceback (most recent call last):
  File "demo/image_demo.py", line 3, in <module>
    from mmdet.apis import inference_detector, init_detector, show_result_pyplot
  File "/home/ubuntu/workspace/mmdetection/mmdet/apis/__init__.py", line 1, in <module>
    from .inference import (async_inference_detector, inference_detector,
  File "/home/ubuntu/workspace/mmdetection/mmdet/apis/inference.py", line 9, in <module>
    from mmdet.core import get_classes
  File "/home/ubuntu/workspace/mmdetection/mmdet/core/__init__.py", line 2, in <module>
    from .bbox import *  # noqa: F401, F403
  File "/home/ubuntu/workspace/mmdetection/mmdet/core/bbox/__init__.py", line 7, in <module>
    from .samplers import (BaseSampler, CombinedSampler,
  File "/home/ubuntu/workspace/mmdetection/mmdet/core/bbox/samplers/__init__.py", line 9, in <module>
    from .score_hlr_sampler import ScoreHLRSampler
  File "/home/ubuntu/workspace/mmdetection/mmdet/core/bbox/samplers/score_hlr_sampler.py", line 3, in <module>
    from mmdet.ops import nms_match
  File "/home/ubuntu/workspace/mmdetection/mmdet/ops/__init__.py", line 2, in <module>
    from .conv_ws import ConvWS2d, conv_ws_2d
  File "/home/ubuntu/workspace/mmdetection/mmdet/ops/conv_ws.py", line 24, in <module>
    class ConvWS2d(nn.Conv2d):
  File "/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/mmcv/utils/registry.py", line 122, in _register
    module_class=cls, module_name=name, force=force)
  File "/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/mmcv/utils/registry.py", line 58, in _register_module
    raise KeyError(f'{module_name} is already registered '
KeyError: 'ConvWS is already registered in conv layer'
@namheegordonkim
Copy link
Author

namheegordonkim commented Jul 8, 2020

Temporary fix: modify mmdet/ops/conv_ws.py and add force=True to the decorator arguments, i.e.

@CONV_LAYERS.register_module(name='ConvWS', force=True)
@CONV_LAYERS.register_module(name='ConvAWS', force=True)

@xvjiarui
Copy link
Collaborator

xvjiarui commented Jul 10, 2020

Hi @namheegordonkim
As #3232 is merged, there basically are two workarounds.

  1. Install latest mmcv and mmdet
  2. Install mmcv==0.6.2 and mmdet==2.2.1

f74066357 added a commit to f74066357/mmdetection_v2.2 that referenced this issue Jul 10, 2020

Verified

This commit was signed with the committer’s verified signature.
@ZwwWayne
Copy link
Collaborator

The issue seems to be resolved. Feel free to reopen it if you have any further questions.

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

3 participants