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

TypeError: init_weights() missing 1 required positional argument: 'pretrained' #1317

Closed
apanand14 opened this issue Sep 3, 2021 · 17 comments

Comments

@apanand14
Copy link

File "tools/train.py", line 189, in
main()
File "tools/train.py", line 163, in main
model.init_weights()
File "C:\Users\topseven\anaconda3\envs\mmcv\lib\site-packages\mmcv\runner\base_module.py", line 117, in init_weights
m.init_weights()
TypeError: init_weights() missing 1 required positional argument: 'pretrained'

@zhouzaida
Copy link
Collaborator

Did you override the init_weights() method in your module?

@apanand14
Copy link
Author

I think so but not sure. I think there is another model.init_weights() in train.py But When I comment it out then I'm able to train the model. I do not know is it right way or Am I missing something?

@zhouzaida
Copy link
Collaborator

What codebase are you using?

@apanand14
Copy link
Author

mmdetection repository and training file from tools/train.py

@zhouzaida
Copy link
Collaborator

please provide your mmdet version and what config you are using?

@apanand14
Copy link
Author

mmcv-full : 1.3.12
mmdet: 2.16.0

When I run with default mask_rcnn and config: mask_rcnn_r50_caffe_fpn_mstrain-poly_1x_coco.py, it runs fine.
Thank you for replying back

@zhouzaida
Copy link
Collaborator

so why the error happened? Did you modify the mask_rcnn model?

@apanand14
Copy link
Author

apanand14 commented Sep 8, 2021

No. Basically I'm using this custom implementation.
https://github.com/zhanggang001/RefineMask
If I run this then I probably got an error. If I comment model.init_weights(), then I'm able to run but I get some errors in test.py during evaluation. I talked to author about it and he said that better us the exact versions of mmcv-full and mmdet to reproduce the output. If you try with the same mmcv-full and mmdet versions and run test.py withput error then let me know please. Thank you in advance

@zhouzaida
Copy link
Collaborator

zhouzaida commented Sep 8, 2021

@hhaAndroid have a look

@hhaAndroid
Copy link
Contributor

@apanand14 Please refer to https://github.com/open-mmlab/mmdetection/blob/master/docs/changelog.md#backwards-incompatible-changes. In v2.12.0 MMDetection, we have adopted init_cfg uniformly, you need to refer to open-mmlab/mmdetection#4750 for custom code. If you still can’t solve it, we will further help you solve it.

@apanand14
Copy link
Author

apanand14 commented Sep 9, 2021

Hello @hhaAndroid , I tried to solve this issue for custom code. But I'm getting same error no matter what I chnage. Is it possible that you look into and help me to solve it please? Here is the custom implementation I use on mmcv-full 1.3.12 and mmdet 2.16.0 . As you mentioned backward incompatibale changes causes above mentioned error. Can you help me to run this custom implementation on mmcv-full and mmdet (latest versions)?

https://github.com/zhanggang001/RefineMask
In this custom implementation there are two custom implementation are done.

  1. refinemask/mmdet/models/roi_heads/refine_roi_head.py and
  2. refinemask/mmdet/models/roi_heads/mask_heads/refine_mask_head.py
  3. Config file: configs/refinemask/coco/r50-refinemask-1x.py

As I told you before, I use init_cfg in cfg file. Also, I do not get any error while I train with default Mask Rcnn. (Training and inference works well). In custom implementation, training works if I make a comment of model.init_weights() but it throws an error (mentioned in title) with it. Please help me out. Thank you in advance!!

@hhaAndroid
Copy link
Contributor

If you do not want to modify the current code, I suggest that your mmdet version should not be higher than v2.12.0, because there is BC-Breaking.

@apanand14
Copy link
Author

Thank you for the reply. I will try to downgrade mmdet version and check it out.

@zhouzaida
Copy link
Collaborator

hi @apanand14 , is there any progress?

@apanand14
Copy link
Author

Hello @zhouzaida , I'm able to run the customized mmdetection by installing the lower versions. Thank you for your help. I will let you know once I change the code on the latest versions of the mmdetection and then it works or not.

@zhouzaida
Copy link
Collaborator

Hello @zhouzaida , I'm able to run the customized mmdetection by installing the lower versions. Thank you for your help. I will let you know once I change the code on the latest versions of the mmdetection and then it works or not.

hi @apanand14 , is there any progress?

@apanand14
Copy link
Author

No, I'm focused on the training and optimizing stuffs with lower versions only. I will let you know in maximum weeks.

@ZwwWayne ZwwWayne closed this as completed Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants