ZJU-lishuang / yolov5_prune

yolov5 prune,Support V2, V3, V4 and V6 versions of yolov5
Apache License 2.0
556 stars 136 forks source link

剪枝后微调 加载模型的时候报错 #73

Open woshituobaye opened 2 years ago

woshituobaye commented 2 years ago

File "/home/nxin/下载/yolov5-v6-prune/prune_finetune.py", line 134, in train cfg_model.load_state_dict(torch.load(weights)['model'])

RuntimeError: Error(s) in loading state_dict for Darknet: size mismatch for module_list.72.Conv2d.weight: copying a param with shape torch.Size([18, 62, 1, 1]) from checkpoint, the shape in current model is torch.Size([255, 62, 1, 1]). size mismatch for module_list.72.Conv2d.bias: copying a param with shape torch.Size([18]) from checkpoint, the shape in current model is torch.Size([255]). size mismatch for module_list.84.Conv2d.weight: copying a param with shape torch.Size([18, 121, 1, 1]) from checkpoint, the shape in current model is torch.Size([255, 121, 1, 1]). size mismatch for module_list.84.Conv2d.bias: copying a param with shape torch.Size([18]) from checkpoint, the shape in current model is torch.Size([255]). size mismatch for module_list.96.Conv2d.weight: copying a param with shape torch.Size([18, 228, 1, 1]) from checkpoint, the shape in current model is torch.Size([255, 228, 1, 1]). size mismatch for module_list.96.Conv2d.bias: copying a param with shape torch.Size([18]) from checkpoint, the shape in current model is torch.Size([255]).

ZJU-lishuang commented 2 years ago

类别数检查一下

gmt710 commented 2 years ago

@woshituobaye , Hello, have you solved this?

gmt710 commented 2 years ago

知道了,需要自己修改下生成的cfg里面的filter