YOLOV5代码复现过程出现的问题

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里,所以这些解决方法的原博客没有记录下来地址。

此博客仅用于个人学习记录,如有侵权请联系删除。

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值