ZjjConan / SimAM

The official pytorch implemention of our ICML-2021 paper "SimAM: A Simple, Parameter-Free Attention Module for Convolutional Neural Networks".
409 stars 36 forks source link

请问如何用mmdection复现? #15

Closed lixz123007 closed 1 year ago

lixz123007 commented 2 years ago

大佬您好,我把github中mmdection文件夹考到了我的mmdection文件夹中,并复制了提供的mask rcnn simam的log中model的config。但是运行的时候提示,ResNetRM is not in the models registry。请问想用mmdection运行您的代码还需要什么?求稍微给点关键词,如果有教程网站就更感激啦? 感谢!

ZjjConan commented 2 years ago

您好,我感觉应该是放的位置不太对,你可以参考一下MMDetection里面如何加入新的backbone来做,那一块有教程解释。

ZjjConan commented 2 years ago

@lixz123007 解决了嘛,最近这一周有点事情,1月中旬后,我再更新一下readme。

lixz123007 commented 2 years ago

@lixz123007 解决了嘛,最近这一周有点事情,1月中旬后,我再更新一下readme。

我按照教程在models/backbones/init.py加入了,from .resnet_simam import ResNetAM 并吧resnet_simam.py和attentions文件夹放入了backbones文件夹。运行mask rcnn simam的log中model的config后报错:

2022-01-02 20:15:16,281 - mmdet - INFO - Set random seed to 823580316, deterministic: False Traceback (most recent call last): File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/registry.py", line 52, in build_from_cfg return obj_cls(*args) File "/home/finch/workspace/mmdetection/mmdet/models/detectors/mask_rcnn.py", line 27, in init init_cfg=init_cfg) File "/home/finch/workspace/mmdetection/mmdet/models/detectors/two_stage.py", line 32, in init self.backbone = build_backbone(backbone) File "/home/finch/workspace/mmdetection/mmdet/models/builder.py", line 20, in build_backbone return BACKBONES.build(cfg) File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/registry.py", line 212, in build return self.build_func(args, **kwargs, registry=self) File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/cnn/builder.py", line 27, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/registry.py", line 45, in build_from_cfg f'{obj_type} is not in the {registry.name} registry') KeyError: 'ResNetRM is not in the models registry'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "tools/train.py", line 185, in main() File "tools/train.py", line 158, in main test_cfg=cfg.get('test_cfg')) File "/home/finch/workspace/mmdetection/mmdet/models/builder.py", line 59, in build_detector cfg, default_args=dict(train_cfg=train_cfg, test_cfg=test_cfg)) File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/registry.py", line 212, in build return self.build_func(*args, **kwargs, registry=self) File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/cnn/builder.py", line 27, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/registry.py", line 55, in build_from_cfg raise type(e)(f'{obj_cls.name}: {e}') KeyError: "MaskRCNN: 'ResNetRM is not in the models registry'"

非常懵逼。不知道哪里出问题了!

lixz123007 commented 2 years ago

我又尝试了一下运行config里面的mask_rcnn_r50simam_fpn_1x_coco.py

报错如下: 2022-01-02 20:47:31,001 - mmdet - INFO - Set random seed to 847853028, deterministic: False Traceback (most recent call last): File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/registry.py", line 52, in build_from_cfg return obj_cls(**args) File "/home/finch/workspace/mmdetection/mmdet/models/backbones/resnet_simam.py", line 198, in init attention_module = functools.partial(simam_module, e_lambda=attention_param) TypeError: the first argument must be callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/registry.py", line 52, in build_from_cfg return obj_cls(*args) File "/home/finch/workspace/mmdetection/mmdet/models/detectors/mask_rcnn.py", line 27, in init init_cfg=init_cfg) File "/home/finch/workspace/mmdetection/mmdet/models/detectors/two_stage.py", line 32, in init self.backbone = build_backbone(backbone) File "/home/finch/workspace/mmdetection/mmdet/models/builder.py", line 20, in build_backbone return BACKBONES.build(cfg) File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/registry.py", line 212, in build return self.build_func(args, **kwargs, registry=self) File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/cnn/builder.py", line 27, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/registry.py", line 55, in build_from_cfg raise type(e)(f'{obj_cls.name}: {e}') TypeError: ResNetAM: the first argument must be callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "tools/train.py", line 185, in main() File "tools/train.py", line 158, in main test_cfg=cfg.get('test_cfg')) File "/home/finch/workspace/mmdetection/mmdet/models/builder.py", line 59, in build_detector cfg, default_args=dict(train_cfg=train_cfg, test_cfg=test_cfg)) File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/registry.py", line 212, in build return self.build_func(*args, **kwargs, registry=self) File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/cnn/builder.py", line 27, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/finch/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/registry.py", line 55, in build_from_cfg raise type(e)(f'{obj_cls.name}: {e}') TypeError: MaskRCNN: ResNetAM: the first argument must be callable 好像是attentions文件出了问题,我再试试看

lixz123007 commented 2 years ago

我尝试了一下,改了这句话 from .attentions.simam_module import simam_module 并运行 mask_rcnn_r50simam_fpn_1x_coco.py 之前的报错都没有了,但是runner出现了问题。目测应该是mmdetection版本不同造成的问题。

JaciusCV commented 2 years ago

我记得添加新的backbone后,需要重新make一下吧