(26)RuntimeError: Error(s) in loading state_dict for YoloBody:size mismatch for yolo_head3.1.weight

运行B_yolov4进行mAP计算的时候报错:

RuntimeError: Error(s) in loading state_dict for YoloBody:
	size mismatch for yolo_head3.1.weight: copying a param with shape torch.Size([75, 256, 1, 1]) from checkpoint, the shape in current model is torch.Size([255, 256, 1, 1]).
	size mismatch for yolo_head3.1.bias: copying a param with shape torch.Size([75]) from checkpoint, the shape in current model is torch.Size([255]).
	size mismatch for yolo_head2.1.weight: copying a param with shape torch.Size([75, 512, 1, 1]) from checkpoint, the shape in current model is torch.Size([255, 512, 1, 1]).
	size mismatch for yolo_head2.1.bias: copying a param with shape torch.Size([75]) from checkpoint, the shape in current model is torch.Size([255]).
	size mismatch for yolo_head1.1.weight: copying a param with shape torch.Size([75, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([255, 1024, 1, 1]).
	size mismatch for yolo_head1.1.bias: copying a param with shape torch.Size([75]) from checkpoint, the shape in current model is torch.Size([255]).

解决方法:

检查train.py中class_names和num_classes都对,所以确定是计算mAP时候调用的几个程序中的问题,最终发现是yolo.py中类别数不对,

"classes_path"      : 'model_data/coco_classes.txt',

改为:

"classes_path"      : 'model_data/voc_classes.txt',

参考:https://github.com/bubbliiiing/yolo3-pytorch/issues/17

https://blog.csdn.net/nangg1047/article/details/116073131

你可能感兴趣的:(神经网络)