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

torch.nn.modules.module.ModuleAttributeError: MaskRCNN: 'Sequential' object has no attribute 'init_weights' #6808

Closed
LZYmixiu opened this issue Dec 16, 2021 · 5 comments
Assignees

Comments

@LZYmixiu
Copy link

LZYmixiu commented Dec 16, 2021

When I training the model which type is maskrcnn, the error likes title was encouraged, dose anyone knows what's going on? or have met this erro before?
The problem seems like in mmcv.
The Traceback is:

Traceback (most recent call last):
  File "/home/ljo4sgh/miniconda3/envs/new-swin-T/lib/python3.7/site-packages/mmcv/utils/registry.py", line 52, in build_from_cfg
    return obj_cls(**args)
  File "/home/ljo4sgh/miniconda3/envs/new-swin-T/lib/python3.7/site-packages/mmdet-2.11.0-py3.7.egg/mmdet/models/detectors/mask_rcnn.py", line 24, in __init__    pretrained=pretrained)
  File "/home/ljo4sgh/miniconda3/envs/new-swin-T/lib/python3.7/site-packages/mmdet-2.11.0-py3.7.egg/mmdet/models/detectors/two_stage.py", line 48, in __init__                                             rixzerogoki" 10:54 16-12月-21
    self.init_weights(pretrained=pretrained)
  File "/home/ljo4sgh/miniconda3/envs/new-swin-T/lib/python3.7/site-packages/mmdet-2.11.0-py3.7.egg/mmdet/models/detectors/two_stage.py", line 78, in init_weights
    self.roi_head.init_weights(pretrained)
  File "/home/ljo4sgh/miniconda3/envs/new-swin-T/lib/python3.7/site-packages/mmdet-2.11.0-py3.7.egg/mmdet/models/roi_heads/standard_roi_head.py", line 48, in init_weights
    self.bbox_head.init_weights()
  File "/home/ljo4sgh/miniconda3/envs/new-swin-T/lib/python3.7/site-packages/torch/nn/modules/module.py", line 779, in __getattr__
    type(self).__name__, name))
torch.nn.modules.module.ModuleAttributeError: 'Sequential' object has no attribute 'init_weights'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./tools/train.py", line 187, in <module>
    main()
  File "./tools/train.py", line 161, in main
    test_cfg=cfg.get('test_cfg'))
  File "/home/ljo4sgh/miniconda3/envs/new-swin-T/lib/python3.7/site-packages/mmdet-2.11.0-py3.7.egg/mmdet/models/builder.py", line 77, in build_detector
    return build(cfg, DETECTORS, dict(train_cfg=train_cfg, test_cfg=test_cfg))
  File "/home/ljo4sgh/miniconda3/envs/new-swin-T/lib/python3.7/site-packages/mmdet-2.11.0-py3.7.egg/mmdet/models/builder.py", line 34, in build
    return build_from_cfg(cfg, registry, default_args)
  File "/home/ljo4sgh/miniconda3/envs/new-swin-T/lib/python3.7/site-packages/mmcv/utils/registry.py", line 55, in build_from_cfg
    raise type(e)(f'{obj_cls.__name__}: {e}')
torch.nn.modules.module.ModuleAttributeError: MaskRCNN: 'Sequential' object has no attribute 'init_weights'

ps: I haven't modified the test_cfg in my own config.

@RangiLyu
Copy link
Member

RangiLyu commented Dec 16, 2021

Could you provide your mmcv version? And which config did you use?

@LZYmixiu
Copy link
Author

my base model is base = '.mask_rcnn/mask_rcnn_r50_fpn_1x_coco.py'
my mmcv version is : mmcv-full 1.4.0

@RangiLyu
Copy link
Member

It seems that your mmdetection version 2.11 has conflicts with the latest mmcv. The weight initializing was changed after #4750. Try to upgrade your mmdetection version. The master branch is 2.19.1 now. Or downgrade your mmcv version.

@LZYmixiu
Copy link
Author

LZYmixiu commented Dec 16, 2021

It seems that your mmdetection version 2.11 has conflicts with the latest mmcv. The weight initializing was changed after #4750. Try to upgrade your mmdetection version. The master branch is 2.19.1 now. Or downgrade your mmcv version.

It still would be torch.nn.modules.module.ModuleAttributeError: 'Sequential' object has no attribute 'init_weights' after I downgrade mmcv-full to 1.2.4
And new error TypeError: MaskRCNN: SwinTransformer: init() got an unexpected keyword argument 'embed_dim' be encouraged after I upgrade mmde to 2.19.1 (In this situation mmcv is 1.4.0)
:(

@LZYmixiu
Copy link
Author

I found it's a mistake form my config file
And the version I used is:
mmcv-full 1.4.0 pypi_0 pypi
mmdet 2.11.0 pypi_0 pypi
mmpycocotools 12.0.3 pypi_0 pypi
Thanks every replier under this issue!

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

2 participants