1.报错:RuntimeError: The size of tensor a (60) must match the size of tensor b (56) at non-singleton dimension 3
原因:权重与yolov5版本不配套,需要下载新的权重文件替代weights中的文件
2.报错:Fusing layers... Model Summary: 224 layers, 7266973 parameters, 0 gradients, 17.0 GFLOPS image 1/2 E:\yolov5-5.0\data\images\bus.jpg: 640x480 4 persons, 1 bus, 1 fire hydrant, Done. (0.196s) image 2/2 E:\yolov5-5.0\data\images\zidane.jpg: 384x640 2
问题:用官方权重测试两张图无结果
解决方法:在detect.py文件第53行加入
cudnn.benchmark = True
Tips:后来删掉这行代码也能出结果,不知道为什么
3.报错:AttributeError: module ‘numpy‘ has no attribute ‘int‘
原因:np.int在NumPy 1.20中已弃用,在NumPy 1.24中已删除。
解决方式:将'np.int'更改为:
np.int_
4.报错:indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) # image, anchor, grid indices
RuntimeError: result type Float can't be cast to the desired output type __int64
原因:cuda/torch版本较高
解决方法:在声明时将网格空间的“增益”转换为长
在Loss.py文件中,将
gain = torch.ones(7, device = device)
替换成
gain = torch.ones(7, device = device).long()
因为当时把问题记录在了OneNote里,所以这些解决方法的原博客没有记录下来地址。
此博客仅用于个人学习记录,如有侵权请联系删除。