gjy3035 / C-3-Framework

An open-source PyTorch code for crowd counting
MIT License
697 stars 200 forks source link

Unexpected key(s) in state_dict #89

Open ZeeRizvee opened 4 years ago

ZeeRizvee commented 4 years ago

I get the following error while running test.py. I am using the vgg16-397923af.pth as a pretrained model. Any help on this will be appreciated. I have already looked into the related issues, but none solved my problem and my issue appears to be a bit different as well. Thanks!

RuntimeError: Error(s) in loading state_dict for CrowdCounter: Missing key(s) in state_dict: "CCN.layer3.0.weight", "CCN.layer3.0.bias", "CCN.layer3.2.weight", "CCN.layer3.2.bias", "CCN.layer3.5.weight", "CCN.layer3.5.bias", "CCN.layer3.7.weight", "CCN.layer3.7.bias", "CCN.layer3.10.weight", "CCN.layer3.10.bias", "CCN.layer3.12.weight", "CCN.layer3.12.bias", "CCN.layer3.14.weight", "CCN.layer3.14.bias", "CCN.layer3.17.weight", "CCN.layer3.17.bias", "CCN.layer3.19.weight", "CCN.layer3.19.bias", "CCN.layer3.21.weight", "CCN.layer3.21.bias", "CCN.layer4.1.weight", "CCN.layer4.1.bias", "CCN.layer4.3.weight", "CCN.layer4.3.bias", "CCN.layer4.5.weight", "CCN.layer4.5.bias", "CCN.layer5.1.weight", "CCN.layer5.1.bias", "CCN.layer5.3.weight", "CCN.layer5.3.bias", "CCN.layer5.5.weight", "CCN.layer5.5.bias", "CCN.fuse_layer5.conv1x1_d1.weight", "CCN.fuse_layer5.conv1x1_d1.bias", "CCN.fuse_layer5.conv1x1_d2.weight", "CCN.fuse_layer5.conv1x1_d2.bias", "CCN.fuse_layer5.conv1x1_d3.weight", "CCN.fuse_layer5.conv1x1_d3.bias", "CCN.fuse_layer5.conv1x1_d4.weight", "CCN.fuse_layer5.conv1x1_d4.bias", "CCN.fuse_layer5.conv_d1.weight", "CCN.fuse_layer5.conv_d1.bias", "CCN.fuse_layer5.conv_d2.weight", "CCN.fuse_layer5.conv_d2.bias", "CCN.fuse_layer5.conv_d3.weight", "CCN.fuse_layer5.conv_d3.bias", "CCN.fuse_layer5.conv_d4.weight", "CCN.fuse_layer5.conv_d4.bias", "CCN.fuse_layer4.conv1x1_d1.weight", "CCN.fuse_layer4.conv1x1_d1.bias", "CCN.fuse_layer4.conv1x1_d2.weight", "CCN.fuse_layer4.conv1x1_d2.bias", "CCN.fuse_layer4.conv1x1_d3.weight", "CCN.fuse_layer4.conv1x1_d3.bias", "CCN.fuse_layer4.conv1x1_d4.weight", "CCN.fuse_layer4.conv1x1_d4.bias", "CCN.fuse_layer4.conv_d1.weight", "CCN.fuse_layer4.conv_d1.bias", "CCN.fuse_layer4.conv_d2.weight", "CCN.fuse_layer4.conv_d2.bias", "CCN.fuse_layer4.conv_d3.weight", "CCN.fuse_layer4.conv_d3.bias", "CCN.fuse_layer4.conv_d4.weight", "CCN.fuse_layer4.conv_d4.bias", "CCN.fuse_layer3.conv1x1_d1.weight", "CCN.fuse_layer3.conv1x1_d1.bias", "CCN.fuse_layer3.conv1x1_d2.weight", "CCN.fuse_layer3.conv1x1_d2.bias", "CCN.fuse_layer3.conv1x1_d3.weight", "CCN.fuse_layer3.conv1x1_d3.bias", "CCN.fuse_layer3.conv1x1_d4.weight", "CCN.fuse_layer3.conv1x1_d4.bias", "CCN.fuse_layer3.conv_d1.weight", "CCN.fuse_layer3.conv_d1.bias", "CCN.fuse_layer3.conv_d2.weight", "CCN.fuse_layer3.conv_d2.bias", "CCN.fuse_layer3.conv_d3.weight", "CCN.fuse_layer3.conv_d3.bias", "CCN.fuse_layer3.conv_d4.weight", "CCN.fuse_layer3.conv_d4.bias", "CCN.count_layer5.avgpool_layer.0.weight", "CCN.count_layer5.avgpool_layer.0.bias", "CCN.count_layer5.maxpool_layer.0.weight", "CCN.count_layer5.maxpool_layer.0.bias", "CCN.count_layer5.conv1x1.0.weight", "CCN.count_layer5.conv1x1.0.bias", "CCN.count_layer4.avgpool_layer.0.weight", "CCN.count_layer4.avgpool_layer.0.bias", "CCN.count_layer4.maxpool_layer.0.weight", "CCN.count_layer4.maxpool_layer.0.bias", "CCN.count_layer4.conv1x1.0.weight", "CCN.count_layer4.conv1x1.0.bias", "CCN.count_layer3.avgpool_layer.0.weight", "CCN.count_layer3.avgpool_layer.0.bias", "CCN.count_layer3.maxpool_layer.0.weight", "CCN.count_layer3.maxpool_layer.0.bias", "CCN.count_layer3.conv1x1.0.weight", "CCN.count_layer3.conv1x1.0.bias", "CCN.layer5_k.0.weight", "CCN.layer5_k.0.bias", "CCN.layer4_k.0.weight", "CCN.layer4_k.0.bias", "CCN.layer3_k.0.weight", "CCN.layer3_k.0.bias", "CCN.layer5_i.0.weight", "CCN.layer5_i.0.bias", "CCN.layer4_i.0.weight", "CCN.layer4_i.0.bias", "CCN.layer3_i.0.weight", "CCN.layer3_i.0.bias", "CCN.layer5_p.0.weight", "CCN.layer5_p.0.bias", "CCN.layer4_p.0.weight", "CCN.layer4_p.0.bias", "CCN.layer3_p.0.weight", "CCN.layer3_p.0.bias". Unexpected key(s) in state_dict: "features.0.weight", "features.0.bias", "features.2.weight", "features.2.bias", "features.5.weight", "features.5.bias", "features.7.weight", "features.7.bias", "features.10.weight", "features.10.bias", "features.12.weight", "features.12.bias", "features.14.weight", "features.14.bias", "features.17.weight", "features.17.bias", "features.19.weight", "features.19.bias", "features.21.weight", "features.21.bias", "features.24.weight", "features.24.bias", "features.26.weight", "features.26.bias", "features.28.weight", "features.28.bias", "classifier.0.weight", "classifier.0.bias", "classifier.3.weight", "classifier.3.bias", "classifier.6.weight", "classifier.6.bias".

deryaguler95 commented 3 years ago

You should use "strict=False" on te error line