问题描述:
运行yolov5下面Tags5的代码出现问题:
Traceback (most recent call last): File "/media/ls/娱乐/yolov5/yolov5-5.0/train.py", line 547, intrain(hyp, opt, device, tb_writer) File "/media/ls/娱乐/yolov5/yolov5-5.0/train.py", line 88, in train model = Model(opt.cfg or ckpt['model'].yaml, ch=3, nc=nc, anchors=hyp.get('anchors')).to(device) # create File "/media/ls/娱乐/yolov5/yolov5-5.0/models/yolo.py", line 93, in __init__ m.stride = torch.tensor([s / x.shape[-2] for x in self.forward(torch.zeros(1, ch, s, s))]) # forward File "/media/ls/娱乐/yolov5/yolov5-5.0/models/yolo.py", line 123, in forward return self.forward_once(x, profile) # single-scale inference, train File "/media/ls/娱乐/yolov5/yolov5-5.0/models/yolo.py", line 139, in forward_once x = m(x) # run File "/home/ls/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/media/ls/娱乐/yolov5/yolov5-5.0/models/common.py", line 32, in forward x = self.cv1(x) File "/home/ls/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/media/ls/娱乐/yolov5/yolov5-5.0/models/common.py", line 60, in forward return self.act(self.bn(self.conv(x))) File "/home/ls/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/home/ls/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 446, in forward return self._conv_forward(input, self.weight, self.bias) File "/home/ls/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 443, in _conv_forward self.padding, self.dilation, self.groups) RuntimeError: Given groups=1, weight of size [512, 1024, 1, 1], expected input[1, 512, 8, 8] to have 1024 channels, but got 512 channels instead
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-xzF3hDHD-1638930734782)(/home/ls/图片/ginen问题截图.png)]
这是由于一些参数没有加载好!!!
- 我们可以看到默认的模型配置文件yaml路径没有指定–在 459 --cfg 参数这一行[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-LT7ZskXR-1638930734785)(file:///home/ls/%E5%9B%BE%E7%89%87/train.png?lastModify=1638929942)]
然后我们指定一个之后
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Nqmo9ss3-1638930734788)(/home/ls/图片/2021-12-08 10-17-09屏幕截图.png)]
然后就可以正常运行了!!!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)