【解决报错】RuntimeError: Error(s) in loading state_dict for Net:size mismatch for classifier.

运行yolov4_deepsort代码时出现报错:

RuntimeError: Error(s) in loading state_dict for Net:
    size mismatch for classifier.4.weight: copying a param with shape torch.Size([751, 256]) from checkpoint, the shape in current model is torch.Size([10, 256]).
    size mismatch for classifier.4.bias: copying a param with shape torch.Size([751]) from checkpoint, the shape in current model is torch.Size([10]).

 报错原因是分类器维度不匹配,将10改成751即可

更改代码位置:deep_sort/deep/model.py  49行位置

class Net(nn.Module):
    def __init__(self, num_classes=751, reid=False):  
    #  将原来的num_classes=10改成num_classes=751即可

更改完成后可正常运行

https://github.com/ZQPei/deep_sort_pytorch/issues/134

猜你喜欢

转载自blog.csdn.net/weixin_47214888/article/details/130079853
今日推荐