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

KeyError: "CascadeRCNN: 'backbone.layers.0.blocks.0.attn.relative_position_bias_table'" #4

Closed
luooofan opened this issue Apr 14, 2021 · 12 comments

Comments

@luooofan
Copy link

Thanks for your work!

I occured the error when I run the code.
Snipaste_2021-04-14_15-43-29

I run the command:
python tools/train.py configs/swin/mydef_cascade_mask_rcnn_swin_small_patch4_window7_mstrain_480-800_giou_4conv1f_adamw_3x_coco.py --cfg-options model.pretrained=./models/cascade_mask_rcnn_swin_small_patch4_window7.pth

How to solve it?

@weiyx16
Copy link
Member

weiyx16 commented Apr 14, 2021

I think the reason is the pretrained model you used is the one finetuned on COCO det, not the one from ImageNet pretrain. You'd better use the corresponding model held on this page.

@luooofan
Copy link
Author

I've tried to print some infomation at there thanks to your reminding.

...
relative_position_bias_table_keys = [k for k in state_dict.keys() if "relative_position_bias_table" in k]
# insert code
print(relative_position_bias_table_keys)
print([k for k in model.state_dict().keys() if "relative_position_bias_table" in k])
...

And I get these:
outputinfo

@luooofan
Copy link
Author

I think the reason is the pretrained model you used is the one finetuned on COCO det, not the one from ImageNet pretrain. You'd better use the corresponding model held on this page.

Maybe this is the keypoint, I'll try it.

@luooofan
Copy link
Author

It works. Thanks.

@weiyx16
Copy link
Member

weiyx16 commented Apr 15, 2021

Good to know!

@JHLEE17
Copy link

JHLEE17 commented May 11, 2021

Thank you. @weiyx16
It works for me too.
but, I wonder why using COCO pre-trained weights is not available.

because I'm trying to train custom detection dataset on Swin Transformer-Object Detection.
It was success that training custom dataset using ImageNet pre-trained weights but,
it wasn't success that training using COCO pre-trained weights.

@hosea7456
Copy link

Thank you. @weiyx16
It works for me too.
but, I wonder why using COCO pre-trained weights is not available.

because I'm trying to train custom detection dataset on Swin Transformer-Object Detection.
It was success that training custom dataset using ImageNet pre-trained weights but,
it wasn't success that training using COCO pre-trained weights.

I had the same problem.

@yinggo
Copy link

yinggo commented May 16, 2021

Thank you. @weiyx16
It works for me too.
but, I wonder why using COCO pre-trained weights is not available.

because I'm trying to train custom detection dataset on Swin Transformer-Object Detection.
It was success that training custom dataset using ImageNet pre-trained weights but,
it wasn't success that training using COCO pre-trained weights.

Does anybody know that? I want to finetune the COCO pre-trained weights to my own dataset.

@bfialkoff
Copy link

What was the conclusion? Which is the correct base model from this page

@hans0809
Copy link

hans0809 commented Apr 6, 2022

What was the conclusion? Which is the correct base model from this page

Hi, did you solve this ? I also encountered it today and did't solve yet.

@swimmant
Copy link

使用config文件中load_from关键字进行加载预训练模型,不要使用参数--cfg-options model.pretrained=<PRETRAIN_MODEL> [model.backbone.use_checkpoint=True] [other optional arguments] 这种方式加载模型

@zccsir
Copy link

zccsir commented Jul 13, 2023

适用于:调用训练好的模型继续优化
configs/base/default_runtime.py
load_from = r"E:\workspace\Python\Pytorch\Swin-Transformer-Object-Detection\mask_rcnn_swin_tiny_patch4_window7.pth"

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

9 participants