zylo117 / Yet-Another-EfficientDet-Pytorch

The pytorch re-implement of the official efficientdet with SOTA performance in real time and pretrained weights.
GNU Lesser General Public License v3.0
5.21k stars 1.27k forks source link

Error(s) in loading state_dict for EfficientDetBackbone #342

Closed williamscott701 closed 4 years ago

williamscott701 commented 4 years ago

RuntimeError Traceback (most recent call last)

in ----> 1 model.load_state_dict(torch.load('logs/coco2017/efficientdet-d2_1_3962.pth')) ~/.conda/envs/python3/lib/python3.7/site-packages/torch/nn/modules/module.py in load_state_dict(self, state_dict, strict) 828 if len(error_msgs) > 0: 829 raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( --> 830 self.__class__.__name__, "\n\t".join(error_msgs))) 831 return _IncompatibleKeys(missing_keys, unexpected_keys) 832 RuntimeError: Error(s) in loading state_dict for EfficientDetBackbone: Missing key(s) in state_dict: "backbone_net.model._blocks.1._expand_conv.conv.weight", "backbone_net.model._blocks.1._bn0.weight", "backbone_net.model._blocks.1._bn0.bias", "backbone_net.model._blocks.1._bn0.running_mean", "backbone_net.model._blocks.1._bn0.running_var". Unexpected key(s) in state_dict: "bifpn.3.p6_w1", "bifpn.3.p5_w1", "bifpn.3.p4_w1", "bifpn.3.p3_w1", "bifpn.3.p4_w2", "bifpn.3.p5_w2", "bifpn.3.p6_w2", "bifpn.3.p7_w2", "bifpn.3.conv6_up.depthwise_conv.conv.weight", "bifpn.3.conv6_up.pointwise_conv.conv.weight", "bifpn.3.conv6_up.pointwise_conv.conv.bias", "bifpn.3.conv6_up.bn.weight", "bifpn.3.conv6_up.bn.bias", "bifpn.3.conv6_up.bn.running_mean", "bifpn.3.conv6_up.bn.running_var", "bifpn.3.conv6_up.bn.num_batches_tracked", "bifpn.3.conv5_up.depthwise_conv.conv.weight", "bifpn.3.conv5_up.pointwise_conv.conv.weight", "bifpn.3.conv5_up.pointwise_conv.conv.bias", "bifpn.3.conv5_up.bn.weight", "bifpn.3.conv5_up.bn.bias", "bifpn.3.conv5_up.bn.running_mean", "bifpn.3.conv5_up.bn.running_var", "bifpn.3.conv5_up.bn.num_batches_tracked", "bifpn.3.conv4_up.depthwise_conv.conv.weight", "bifpn.3.conv4_up.pointwise_conv.conv.weight", "bifpn.3.conv4_up.pointwise_conv.conv.bias", "bifpn.3.conv4_up.bn.weight", "bifpn.3.conv4_up.bn.bias", "bifpn.3.conv4_up.bn.running_mean", "bifpn.3.conv4_up.bn.running_var", "bifpn.3.conv4_up.bn.num_batches_tracked", "bifpn.3.conv3_up.depthwise_conv.conv.weight", "bifpn.3.conv3_up.pointwise_conv.conv.weight", "bifpn.3.conv3_up.pointwise_conv.conv.bias", "bifpn.3.conv3_up.bn.weight", "bifpn.3.conv3_up.bn.bias", "bifpn.3.conv3_up.bn.running_mean", "bifpn.3.conv3_up.bn.running_var", "bifpn.3.conv3_up.bn.num_batches_tracked", "bifpn.3.conv4_down.depthwise_conv.conv.weight", "bifpn.3.conv4_down.pointwise_conv.conv.weight", "bifpn.3.conv4_down.pointwise_conv.conv.bias", "bifpn.3.conv4_down.bn.weight", "bifpn.3.conv4_down.bn.bias", "bifpn.
zylo117 commented 4 years ago

you need to specify the network architecture before inference, loading a d2 weights into a d0 network is not possible

williamscott701 commented 4 years ago

I cant thank you enough. Didnt notice the compound_coef = 0. Thank you so much :)

ValentinaMiller commented 2 years ago

Hey, I have the same problem. However, I don't quite understand the solution, could you maybe help me understand it?