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

RuntimeError: Error(s) in loading state_dict for SSD: #3

Open
Shk-aftab opened this issue May 23, 2021 · 11 comments
Open

RuntimeError: Error(s) in loading state_dict for SSD: #3

Shk-aftab opened this issue May 23, 2021 · 11 comments

Comments

@Shk-aftab
Copy link

Shk-aftab commented May 23, 2021

Traceback (most recent call last):
File "test.py", line 592, in
net.load_state_dict(torch.load(args.trained_model))
File "E:\Aftab\X-Ray-Baggage-Scanning\OPIXray\env\lib\site-packages\torch\nn\modules\module.py", line 830, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for SSD:
Missing key(s) in state_dict: "_conf.0.weight", "_conf.0.bias", "_conf.1.weight", "_conf.1.bias", "_conf.2.weight", "_conf.2.bias", "_conf.3.weight", "_conf.3.bias", "_conf.4.weight", "_conf.4.bias", "_conf.5.weight", "_conf.5.bias", "edge_conv2d.weight_const_hori", "edge_conv2d.weight_hori", "edge_conv2d.gamma", "edge_conv2d.weight_const_vertical", "edge_conv2d.weight_vertical", "edge_conv2d.conv2d_1_1.conv2d_1_1.weight", "edge_conv2d.conv2d_1_1.conv2d_1_1.bias", "edge_conv2d.conv2d_1_attention.conv2d_1_attention.weight", "edge_conv2d.conv2d_1_attention.conv2d_1_attention.bias", "edge_conv2d.conv2d_2_attention.conv2d_2_attention.weight", "edge_conv2d.conv2d_2_attention.conv2d_2_attention.bias", "edge_conv2d.conv2d_3_attention.conv2d_3_attention.weight", "edge_conv2d.conv2d_3_attention.conv2d_3_attention.bias", "edge_conv2d.conv2d_4_attention.conv2d_4_attention.weight", "edge_conv2d.conv2d_4_attention.conv2d_4_attention.bias", "edge_conv2d.conv2d_5_attention.conv2d_5_attention.weight", "edge_conv2d.conv2d_5_attention.conv2d_5_attention.bias", "edge_conv2d.conv2d_1_rgb_attention.conv2d_1_rgb_attention.weight", "edge_conv2d.conv2d_1_rgb_attention.conv2d_1_rgb_attention.bias", "edge_conv2d.conv2d_2_rgb_attention.conv2d_2_rgb_attention.weight", "edge_conv2d.conv2d_2_rgb_attention.conv2d_2_rgb_attention.bias", "edge_conv2d.conv2d_3_rgb_attention.conv2d_3_rgb_attention.weight", "edge_conv2d.conv2d_3_rgb_attention.conv2d_3_rgb_attention.bias", "edge_conv2d.conv2d_4_rgb_attention.conv2d_4_rgb_attention.weight", "edge_conv2d.conv2d_4_rgb_attention.conv2d_4_rgb_attention.bias", "edge_conv2d.conv2d_5_rgb_attention.conv2d_5_rgb_attention.weight", "edge_conv2d.conv2d_5_rgb_attention.conv2d_5_rgb_attention.bias", "edge_conv2d.GatedConv2dWithActivation.conv2d.weight", "edge_conv2d.GatedConv2dWithActivation.conv2d.bias", "edge_conv2d.GatedConv2dWithActivation.mask_conv2d.weight", "edge_conv2d.GatedConv2dWithActivation.mask_conv2d.bias", "edge_conv2d.GatedConv2dWithActivation.batch_norm2d.weight", "edge_conv2d.GatedConv2dWithActivation.batch_norm2d.bias", "edge_conv2d.GatedConv2dWithActivation.batch_norm2d.running_mean", "edge_conv2d.GatedConv2dWithActivation.batch_norm2d.running_var", "edge_conv2d.conv2d_1_rgb_red_concat_5.conv2d_1_rgb_red_concat_5.weight", "edge_conv2d.conv2d_1_rgb_red_concat_5.conv2d_1_rgb_red_concat_5.bias", "edge_conv2d.conv2d_1_rgb_red_concat_10.conv2d_1_rgb_red_concat_10.weight", "edge_conv2d.conv2d_1_rgb_red_concat_10.conv2d_1_rgb_red_concat_10.bias", "edge_conv2d.conv2d_1_rgb_red_concat_15.conv2d_1_rgb_red_concat_15.weight", "edge_conv2d.conv2d_1_rgb_red_concat_15.conv2d_1_rgb_red_concat_15.bias".
Unexpected key(s) in state_dict: "conf.0.weight", "conf.0.bias", "conf.1.weight", "conf.1.bias", "conf.2.weight", "conf.2.bias", "conf.3.weight", "conf.3.bias", "conf.4.weight", "conf.4.bias", "conf.5.weight", "conf.5.bias".
size mismatch for vgg.0.weight: copying a param with shape torch.Size([64, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 4, 3, 3]).

@OPIXray-author why it is showing such error while loading the SSD model?

@LoveIsAGame
Copy link

Can you share with me the download address of opixray dataset?thanks!!

@LittleFoodie
Copy link

我也想要一份数据集地址,求求了,谢谢!

@2429581027
Copy link

我也遇到了这个维度问题,请问您解决了么,是直接将vgg的输入改成4通道么,期待您的回复!

@2429581027
Copy link

I also encountered this dimension problem. Did you solve it? Did you directly change the input of vgg to 4 channels? Looking forward to your reply!

@LittleFoodie
Copy link

LittleFoodie commented Aug 18, 2022 via email

@2429581027
Copy link

有截图吗,我有点不太记得这个问题了

------------------ 原始邮件 ------------------ 发件人: "OPIXray-author/OPIXray" @.>; 发送时间: 2022年8月17日(星期三) 晚上6:58 @.>; @.@.>; 主题: Re: [OPIXray-author/OPIXray] RuntimeError: Error(s) in loading state_dict for SSD: (#3) 我也遇到了这个维度问题,请问您解决了么,是直接将vgg的输入改成4通道么,期待您的回复! — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
非常感谢您的回复,就是 forward() 中输入tensor首先经过了这个“self.edge_conv2d()”,也就是DOAM模块,输出是一个4通道的tensor,但是vgg的第一个卷积就是3通道的 “self.vgg[0] :Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))”所以出现了这个错误,我的做法是在DOAM模块的最后一层添加了一个卷积“torch.nn.Conv2d(4, 3, kernel_size=3, padding=1)”,请问您是怎么解决的呢,另外我把这个DOAM模块迁移到了yolov5上,训练速度异常的慢,请问您遇到过么,这是合理的么。
图片

@LittleFoodie
Copy link

LittleFoodie commented Aug 18, 2022 via email

@2429581027
Copy link

同样感谢您的回复,最近在做安检的目标检测任务,感觉好难啊,感谢回复

@LittleFoodie
Copy link

LittleFoodie commented Aug 18, 2022 via email

@2429581027
Copy link

可以多交流,好难,祝好

@YaToou
Copy link

YaToou commented Dec 13, 2023

是这个方向很难吗还是创新很难呢

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

5 participants