运行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',版权声明:本文为weixin_40227656原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。