yolo3-pytorch
yolo3-pytorch copied to clipboard
[predict.py]Error(s) in loading state_dict for YoloBody
麻烦帮忙看看是啥问题么?谢谢 在根据B站教程中的P8测试完成后,运行predict.py后报错,报错日志如下:
(pytorch_gpu_0627) G:\0-App\8-Code\0CodeProject\yolo3-pytorch>python predict.py
Loading weights into state dict...
Traceback (most recent call last):
File "predict.py", line 7, in <module>
yolo = YOLO()
File "G:\0-App\8-Code\0CodeProject\yolo3-pytorch\yolo.py", line 44, in __init__
self.generate()
File "G:\0-App\8-Code\0CodeProject\yolo3-pytorch\yolo.py", line 65, in generate
self.net.load_state_dict(state_dict)
File "G:\0-App\8-Code\Anaconda\envs\pytorch_gpu_0627\lib\site-packages\torch\nn\modules\module.py", line 845, in load_state_dict
self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for YoloBody:
size mismatch for last_layer0.6.weight: copying a param with shape torch.Size([75, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([15, 1024, 1, 1]).
size mismatch for last_layer0.6.bias: copying a param with shape torch.Size([75]) from checkpoint, the shape in current model is torch.Size([15]).
size mismatch for last_layer1.6.weight: copying a param with shape torch.Size([75, 512, 1, 1]) from checkpoint, the shape in current model is torch.Size([15, 512, 1, 1]).
size mismatch for last_layer1.6.bias: copying a param with shape torch.Size([75]) from checkpoint, the shape in current model is torch.Size([15]).
size mismatch for last_layer2.6.weight: copying a param with shape torch.Size([75, 256, 1, 1]) from checkpoint, the shape in current model is torch.Size([15, 256, 1, 1]).
size mismatch for last_layer2.6.bias: copying a param with shape torch.Size([75]) from checkpoint, the shape in current model is torch.Size([15]).
注意修改model_path和classpath,训练的时候需要修改config里面的numclasses
注意修改model_path和classpath,训练的时候需要修改config里面的numclasses
谢谢,另外请教一下,如果希望用外置摄像头进行视频的解析,怎么做呢? 有没有什么建议,感谢
您好,请问一下这个问题您解决了么?那个上面所说的config文件在哪阿?我用的pytorch跑的,也在预测的时候出现了这个问题,很头疼,麻烦您了
@EternalHXP 您好,请问您的这个问题解决了吗?是怎么解决的?
RuntimeError: Error(s) in loading state_dict for YoloBody: size mismatch for last_layer0.6.weight: copying a param with shape torch.Size([21, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([18, 1024, 1, 1]). size mismatch for last_layer0.6.bias: copying a param with shape torch.Size([21]) from checkpoint, the shape in current model is torch.Size([18]). size mismatch for last_layer1.6.weight: copying a param with shape torch.Size([21, 512, 1, 1]) from checkpoint, the shape in current model is torch.Size([18, 512, 1, 1]). size mismatch for last_layer1.6.bias: copying a param with shape torch.Size([21]) from checkpoint, the shape in current model is torch.Size([18]). size mismatch for last_layer2.6.weight: copying a param with shape torch.Size([21, 256, 1, 1]) from checkpoint, the shape in current model is torch.Size([18, 256, 1, 1]). size mismatch for last_layer2.6.bias: copying a param with shape torch.Size([21]) from checkpoint, the shape in current model is torch.Size([18]). 你好我也碰到了同样的问题,但是我都改了的
多加了1
@bubbliiiing 好的,谢谢。