(myconda) root@c62f91247b39:/mnt/yolov4-tiny-pytorch# python predict.py
Traceback (most recent call last):
File "predict.py", line 14, in <module>
yolo = YOLO()
File "/mnt/yolov4-tiny-pytorch/yolo.py", line 97, in __init__
self.generate()
File "/mnt/yolov4-tiny-pytorch/yolo.py", line 108, in generate
self.net.load_state_dict(torch.load(self.model_path, map_location=device))
File "/root/miniconda3/envs/myconda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for YoloBody:
size mismatch for yolo_headP5.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_headP5.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_headP4.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_headP4.1.bias: copying a param with shape torch.Size([75]) from checkpoint, the shape in current model is torch.Size([255]).
训练时用的是yolov4_tiny_weights_coco.pth权重文件
yolo.py修改部分如下: