yolov5lite v1.4 踩坑记录

yolov5lite v1.4
1.报错 AttributeError: module ‘numpy’ has no attribute ‘int’.
np.int was a deprecated alias for the builtin int. To avoid this error in existing code, use int by itself. Doing this will not modify any behavior and is safe. When replacing np.int, you may wish to use e.g. np.int64 or np.int32 to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

原因:从 NumPy 1.20 开始,np.int 已经被弃用(deprecated)。np.int 改为 np.int_ 或者 np.int32 或者 np.int64
详见 https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

解决方法:根据v1.4的requirements.txt的要求,可以使用conda命令,实现numpy降级

conda install numpy=1.xx.x

还可以将代码中的 np.int 改为 int。使用 int 本身并不会改变代码的行为,因此是安全的。如果希望指定精度,可以把np.int 改为 np.int_ 或者 np.int32 或者 np.int64。如果想查看当前代码中的使用情况,可以参考官方说明文档。

2.RuntimeError: result type Float can‘t be cast to the desired output type __int64

原因:在 PyTorch 1.7 版本中,long() 被废弃,推荐使用 int() 或者直接省略。所以如果使用 PyTorch 1.7 或更新版本,就不能像以前那样在张量后面加上 .long()

解决方法:
1.定位utils文件夹下的loss.py,将 gain = torch.ones(7, device=targets.device).long() 改为 gain = torch.ones(7, device=targets.device).int() 或者直接省略后面的 .int()

2.PyTorch降级
去官网:https://pytorch.org/get-started/previous-versions/ 查看相应命令
我的环境是CUDA 12.0.1 ,CUDA可向下兼容(通常情况下,较新版本的 CUDA 驱动能够向下兼容较老版本的 PyTorch),必须要注意版本的对应性,可参考此,将PyTorch降级为1.11.0

# CUDA 10.2
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=10.2 -c pytorch
 
# CUDA 11.3
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch
 
# CPU Only
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cpuonly -c pytorch

3.OSError: [WinError 1455] 页面文件太小,无法完成操作。
原因:这个错误提示表明在加载 torch 库所依赖的一个 DLL 文件时出现了问题,这个 DLL 文件名为 cudnn_adv_infer64_8.dll。具体来说,这个 DLL 文件是 NVIDIA cuDNN 库中的一个组成部分,用于加速深度学习计算。这个错误可能是由于系统中的页面文件(也称虚拟内存)过小导致的。页面文件是一种特殊的文件,用于扩充系统的物理内存,以便运行更多的应用程序或进程。如果页面文件太小,就可能无法同时运行多个应用程序或进程,从而导致类似的错误。

解决方法:
可以看看该链接的方法 [人工智能-深度学习-80]:开发环境 - OSError: [WinError 1455] 页面文件太小,无法完成训练问题的多种解决办法
我的解决方法是调整参数,–workers 参数从 8调整到2,–batch-siz 和**–epochs**调小,其中 --workers: 数据加载器使用的进程数。

4.AttributeError: ‘Upsample’ object has no attribute ‘recompute_scale_factor’
原因:有可能是PyTorch版本兼容性问题
解决方法:参考此链接 YOLOV5 训练好模型测试时出现问题:AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘的解决方法

    def forward(self, input: Tensor) -> Tensor:
        return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners
#return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners,recompute_scale_factor=self.recompute_scale_factor)

5.改为笔记本自带摄像头,出现TypeError: argument of type ‘int‘ is not iterable
原因:这个错误通常是由于在代码中使用了迭代器或者可迭代对象,但是传入的参数不是可迭代对象,而是一个整数类型的值。
解决方案:目标检测----yolov5调用本地摄像头报错TypeError: argument of type ‘int‘ is not iterable
定位 utils/dataset.py ,修改279行代码为:

 if type(url)== type('abc') and('youtube.com/' in url or 'youtu.be/' in url):

总结:全看运气!!!

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值