open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.29k stars 9.42k forks source link

MaskRCNN not in Model Registry #10052

Open yCobanoglu opened 1 year ago

yCobanoglu commented 1 year ago

Prerequisite

Task

I'm using the official example scripts/configs for the officially supported tasks/models/datasets.

Branch

master branch https://github.com/open-mmlab/mmdetection version 3.0.0

Environment

""

Reproduces the problem - code sample

my folder structure:

.venv src/ src/mmdetection/configs # here all configs from master branch copied src/mmdetection/custom_configs #here is my custom config file used for training src/mmdetection/tools/train.py #train.py from master 3.0 branch

custom_config.py _base_ has absolute path to config file

_base_ = "mmdetection/configs/mask_rcnn/mask_rcnn_r50_fpn_1x_coco.py"

Also the train.py is broken.

env_cfg=cfg.get('env_cfg') has to be env_cfg=cfg.get('env_cfg', {})

Reproduces the problem - command or script

""

Reproduces the problem - error message

    raise KeyError(
KeyError: 'MaskRCNN is not in the model registry. Please check whether the value of `MaskRCNN` 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'

Additional information

No response

yCobanoglu commented 1 year ago

If i clone the complete repo then i can get it to work. But how can i use the configs from this repo without having to clone the complete repo. I want to install mmdet in .venv and use the configs from the config folder.

RangiLyu commented 1 year ago

You can set _base_ = "mmdet::mask_rcnn/mask_rcnn_r50_fpn_1x_coco.py"

BAI-721 commented 1 year ago

I also have a similar problem. System environment: MMEngine: 0.7.0,MMCV: 2.0.0rc4,MMDet: 3.0.0rc6

-mmengine - WARNING - Failed to import mmdet.models, please check the location of the registry model is correct. Traceback (most recent call last): File "/home/../tools/train.py", line 124, in main() File "/home/../tools/train.py", line 113, in main runner = Runner.from_cfg(cfg) File "/home/./anaconda3/lib/python3.9/site-packages/mmengine/runner/runner.py", line 439, in from_cfg runner = cls( File "/home/./anaconda3/lib/python3.9/site-packages/mmengine/runner/runner.py", line 406, in init self.model = self.build_model(model) File "/home/./anaconda3/lib/python3.9/site-packages/mmengine/runner/runner.py", line 808, in build_model model = MODELS.build(model) File "/home/./anaconda3/lib/python3.9/site-packages/mmengine/registry/registry.py", line 548, in build return self.build_func(cfg, *args, **kwargs, registry=self) File "/home/./anaconda3/lib/python3.9/site-packages/mmengine/registry/build_functions.py", line 241, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/./anaconda3/lib/python3.9/site-packages/mmengine/registry/build_functions.py", line 100, in build_from_cfg raise KeyError( KeyError: 'FasterRCNN is not in the model registry. Please check whether the value of FasterRCNN 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'

FasterRCNN and MaskRCNN both reported the same error.

BAI-721 commented 1 year ago

I also have a similar problem. System environment: MMEngine: 0.7.0,MMCV: 2.0.0rc4,MMDet: 3.0.0rc6

-mmengine - WARNING - Failed to import mmdet.models, please check the location of the registry model is correct. Traceback (most recent call last): File "/home/../tools/train.py", line 124, in main() File "/home/../tools/train.py", line 113, in main runner = Runner.from_cfg(cfg) File "/home/./anaconda3/lib/python3.9/site-packages/mmengine/runner/runner.py", line 439, in from_cfg runner = cls( File "/home/./anaconda3/lib/python3.9/site-packages/mmengine/runner/runner.py", line 406, in init self.model = self.build_model(model) File "/home/./anaconda3/lib/python3.9/site-packages/mmengine/runner/runner.py", line 808, in build_model model = MODELS.build(model) File "/home/./anaconda3/lib/python3.9/site-packages/mmengine/registry/registry.py", line 548, in build return self.build_func(cfg, *args, **kwargs, registry=self) File "/home/./anaconda3/lib/python3.9/site-packages/mmengine/registry/build_functions.py", line 241, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/./anaconda3/lib/python3.9/site-packages/mmengine/registry/build_functions.py", line 100, in build_from_cfg raise KeyError( KeyError: 'FasterRCNN is not in the model registry. Please check whether the value of FasterRCNN 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'

FasterRCNN and MaskRCNN both reported the same error.

I seem to have resolved this issue, and all modules show that they have not been registered before resolving it. Just add it in tools/train.py:

from mmdet.utils import register_all_modules register_all_modules()

clora16 commented 1 year ago

I encountered the same error. In my case, the following description was missing from the config file. So I added it to the config file. That fixed it.

default_scope = 'mmdet'
eii-shi commented 1 year ago

I encountered the same error. In my case, the following description was missing from the config file. So I added it to the config file. That fixed it.

default_scope = 'mmdet'

I also realized that

matthost commented 7 months ago

I saw this when accidentally running an mmdet 2.x config (probably due to the missing default_scope)

shenyingying commented 6 months ago

what about new register a model ?遇到同样的问题,