File "/root/.pycharm_helpers/pydev/pydevd.py", line 1491, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/root/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/data/yolov5/pruneEagleEye.py", line 153, in <module>
rand_prune_and_eval(model, ignore_idx, opt)
File "/data/yolov5/pruneEagleEye.py", line 65, in rand_prune_and_eval
compact_model = Model(pruned_yaml, pruning=False).to(device)
File "/data/yolov5/models/yolo_prune.py", line 325, in __init__
m.stride = torch.tensor([s / x.shape[-2] for x in forward(torch.zeros(1, ch, s, s))]) # forward
File "/data/yolov5/models/yolo_prune.py", line 324, in <lambda>
forward = lambda x: self.forward(x)[0] if isinstance(m, Segment) else self.forward(x)
File "/data/yolov5/models/yolo_prune.py", line 340, in forward
return self._forward_once(x, profile, visualize) # single-scale inference, train
File "/data/yolov5/models/yolo_prune.py", line 250, in _forward_once
x = m(x) # run
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/container.py", line 139, in forward
python-BaseException
input = module(input)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/data/yolov5/models/common.py", line 805, in forward
return self.cv3(torch.cat((self.m(self.cv1(x)), self.cv2(x)), 1))
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/data/yolov5/models/common.py", line 90, in forward
return self.act(self.bn(self.conv(x)))
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 443, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 439, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Given groups=1, weight of size [64, 56, 1, 1], expected input[1, 128, 32, 32] to have 56 channels, but got 128 channels instead
@Gumpest 你好,支持把yolov5s-pruning.yaml中的nn.Upsample替换成nn.ConvTranspose2d进行prune吗?我进行替换后,按照给的文档训练一遍模型后,运行pruneEagleEye.py报错:
这是训练的结构:
下面是搜索最优子网结构: