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

KeyError when Test #7

Closed
cgy-01 opened this issue Apr 8, 2024 · 6 comments
Closed

KeyError when Test #7

cgy-01 opened this issue Apr 8, 2024 · 6 comments

Comments

@cgy-01
Copy link

cgy-01 commented Apr 8, 2024

When I follow the steps to configure the environment and run Test, I get the error “KeyError: 'BAN_MLPDecoder is already registered in model at opencd.models.decode_heads.ban_utils'”, how do I fix it?

@likyoo
Copy link
Owner

likyoo commented Apr 10, 2024

try this version of opencd

@likyoo
Copy link
Owner

likyoo commented Apr 22, 2024

Please provide full error reporting information, or just use open-cd, which now supports BAN.

@XinzheGeng
Copy link

XinzheGeng commented May 6, 2024

作者你好,我遇到了同样的问题,以下是完整报错信息:
Traceback (most recent call last):
File "test.py", line 8, in
import opencd_custom # noqa: F401,F403
File "/home/gengxz/projects/BAN/opencd_custom/init.py", line 1, in
from .models import * # noqa: F401,F403
File "/home/gengxz/projects/BAN/opencd_custom/models/init.py", line 2, in
from .decode_heads import *
File "/home/gengxz/projects/BAN/opencd_custom/models/decode_heads/init.py", line 1, in
from .ban import BitemporalAdapterHead
File "/home/gengxz/projects/BAN/opencd_custom/models/decode_heads/ban.py", line 13, in
from .ban_utils import BridgeLayer
File "/home/gengxz/projects/BAN/opencd_custom/models/decode_heads/ban_utils.py", line 285, in
class BAN_MLPDecoder(BaseModule):
File "/root/anaconda3/envs/BAN/lib/python3.8/site-packages/mmengine/registry/registry.py", line 666, in _register
self._register_module(module=module, module_name=name, force=force)
File "/root/anaconda3/envs/BAN/lib/python3.8/site-packages/mmengine/registry/registry.py", line 611, in _register_module
raise KeyError(f'{name} is already registered in {self.name} '
KeyError: 'BAN_MLPDecoder is already registered in model at opencd.models.decode_heads.ban_utils'

另外,我尝试了在test.py中直接import opencd,会有以下报错:
Traceback (most recent call last):
File "test.py", line 115, in
main()
File "test.py", line 108, in main
runner = Runner.from_cfg(cfg)
File "/root/anaconda3/envs/BAN/lib/python3.8/site-packages/mmengine/runner/runner.py", line 462, in from_cfg
runner = cls(
File "/root/anaconda3/envs/BAN/lib/python3.8/site-packages/mmengine/runner/runner.py", line 429, in init
self.model = self.build_model(model)
File "/root/anaconda3/envs/BAN/lib/python3.8/site-packages/mmengine/runner/runner.py", line 836, in build_model
model = MODELS.build(model)
File "/root/anaconda3/envs/BAN/lib/python3.8/site-packages/mmengine/registry/registry.py", line 570, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/root/anaconda3/envs/BAN/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 232, in build_model_from_cfg
return build_from_cfg(cfg, registry, default_args)
File "/root/anaconda3/envs/BAN/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 100, in build_from_cfg
raise KeyError(
KeyError: 'DualSiamEncoderDecoder is not in the opencd::model registry. Please check whether the value of DualSiamEncoderDecoder is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module'

@likyoo
Copy link
Owner

likyoo commented May 6, 2024

使用这个版本的open-cd作为依赖:https://github.com/likyoo/open-cd/tree/f05e7fdfe1e0f9a9afa9d6c063ea03b43345226e

或者直接使用最新版的open-cd

@XinzheGeng
Copy link

使用这个版本的open-cd作为依赖:https://github.com/likyoo/open-cd/tree/f05e7fdfe1e0f9a9afa9d6c063ea03b43345226e

或者直接使用最新版的open-cd

感谢,已通过直接使用open-cd中的BAN解决

@likyoo likyoo closed this as completed May 6, 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

4 participants
@likyoo @XinzheGeng @cgy-01 and others