-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fix beit model converter #1616
fix beit model converter #1616
Conversation
In the mmseg implementation, the pre-trained model is loaded in mmseg/models/backbones/beit.py, so the 'backbone' prefix is not needed. Are you using our tools/model_converters/beit2mmseg.py script in your own codebase? Please see the other model_converters scripts and refer to the implementation in beit.py. Also, for mmsegmentation/mmseg/models/backbones/beit.py Line 507 in 46326f6
. These pre-trained keys are not needed in the downstream task. |
@ ZhaoYi1222 What do you think about this?
|
Sorry for the delay. I try to reproduce the result shown in
So I download model from Then I use
to convert the model. When I train the model using --load-from, the log shows Maybe I make some mistakes in my training scripts, I think some guidance about training can be added to README.md?
I run training based on mmsegmentation and try to follow the guidance. Also, in
I think if k.startswith('patch_embed'), key would be add twice in line 17 and 29. Thanks again for your generous help. @linfangjian01 @MeowZheng |
Thx. I think 'patch_embed' can be modified with reference to https://github.com/ZhaoYi1222/mmsegmentation/blob/0ca30ef84579ce4c62aa3aac1ab3769672b389bc/tools/model_converters/beit2mmseg.py#L23-L24 and other parts can be kept. In addition the training can be referred to https://github.com/open-mmlab/mmsegmentation/blob/master/docs/en/train.md. The pretrain path can be modified in
|
or use |
I have modified the code according to your suggestion. Thanks.
I have modified the code according to your suggestion. Thanks. @linfangjian01 |
Thanks. |
* fix beit model converter * Update beit2mmseg.py I have modified the code according to your suggestion. Thanks.
* fix beit model converter * Update beit2mmseg.py I have modified the code according to your suggestion. Thanks.
…tasets.md` and `installation.md` (open-mmlab#1616) * add some docs * refine installation.md
Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
Motivation
The script in
tools/model_converters/beit2mmseg.py
doesn't match the key of models between the official repo and MMSegmentation style (e.g. backbone.*).The training log shows lots of keys in
missing keys in source state_dict
.Trainging result after 1500 iteration:
| aAcc | mIoU | mAcc |
| 39.95 | 1.97 | 3.46 |
Modification
I modify
tools/model_converters/beit2mmseg.py
.Now the warnings of missing keys related to 'backbone' disappear.
Trainging result after 1500 iteration:
| aAcc | mIoU | mAcc |
| 60.4 | 6.21 | 9.4 |
BC-breaking (Optional)
Use cases (Optional)
Checklist