open-mmlab / mmpretrain

OpenMMLab Pre-training Toolbox and Benchmark
https://mmpretrain.readthedocs.io/en/latest/
Apache License 2.0
3.49k stars 1.08k forks source link

[Bug] mmcls and mmseg clash with KeyError: 'ShiftWindowMSA is already registered in attention' #369

Closed damonmaria closed 3 years ago

damonmaria commented 3 years ago

Describe the bug

Both mmcls (0.13.0) and mmseg (0.15.0) have:

@ATTENTION.register_module()
class ShiftWindowMSA(BaseModule):
    ...

To Reproduce

The command you executed.

>>> import mmcls.models.utils
>>> import mmseg.models.backbones
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/tannery/model-etl/.venv/lib/python3.8/site-packages/mmseg/models/__init__.py", line 1, in <module>
    from .backbones import *  # noqa: F401,F403
  File "/home/ubuntu/tannery/model-etl/.venv/lib/python3.8/site-packages/mmseg/models/backbones/__init__.py", line 9, in <module>
    from .swin import SwinTransformer
  File "/home/ubuntu/tannery/model-etl/.venv/lib/python3.8/site-packages/mmseg/models/backbones/swin.py", line 201, in <module>
    class ShiftWindowMSA(BaseModule):
  File "/home/ubuntu/tannery/model-etl/.venv/lib/python3.8/site-packages/mmcv/utils/registry.py", line 309, in _register
    self._register_module(
  File "/home/ubuntu/tannery/model-etl/.venv/lib/python3.8/site-packages/mmcv/utils/registry.py", line 244, in _register_module
    raise KeyError(f'{name} is already registered '
KeyError: 'ShiftWindowMSA is already registered in attention'

Post related information

  1. The output of pip list | grep "mmcv\|mmcls\|^torch"
    mmcls                    0.13.0
    mmcv-full                1.3.9
    mmsegmentation           0.15.0
    torch                    1.8.0
    torch-optimizer          0.1.0
    torchvision              0.9.0
  2. Your config file if you modified it or created a new one. N/A
  3. Your train log file if you meet the problem during training. N/A
  4. Other code you modified in the mmcls folder. None
mzr1996 commented 3 years ago

Thanks for your report, we will try to solve it recently.

mzr1996 commented 3 years ago

Should solved by #375