跑yolov5-obb时的错误

前言.

最近因为项目的原因,要使用检测斜框的模型,就学习了一下yolov5-obb。

当然,在配置环境和使用时也是遇到了许多问题,记下了一些认为比较重要的,

使用的代码是这个大佬的:https://github.com/hukaixuan19970627/yolov5_obb


1. AttributeError: module 'numpy' has no attribute 'int'.

原因:np.int在NumPy 1.20中已弃用,在NumPy 1.24中已删除。

解决方式把有报错的文件里的np.int更改为np.int_。。或者改成int也是可以

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

解决方法修改【utils】中的【loss.py】里面的两处内容

          1)打开你的【utils】文件下的【loss.py】

        2)按【Ctrl】+【F】打开搜索功能,输入【for i in range(self.nl)】找到后将anchors = self.anchors[i]替换为 anchors, shape = self.anchors[i], p[i].shape。输入【indices.append】找到下面的一行内容: 替换为以下内容indices.append((b, a, gj.clamp_(0, shape[2] - 1), gi.clamp_(0, shape[3] - 1)))  # image, anchor, grid

3.RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

解决方法在nms_rotated_wrapper.py中把ori_inds = torch.arange(dets_th.size(0)) # 0 ~ n-1

替换为ori_inds = torch.arange(dets_th.size(0)).to('cuda') # 0 ~ n-1。即把数据也放到GPU中

4.AttributeError: 'FreeTypeFont' object has no attribute 'getsize' AttributeError: 'FreeTypeFont' object has no attribute 'getsize' Results saved to runs\train\exp

原因:安装了新版本的Pillow。

解决方法降到9.5即可----pip install Pillow==9.5

5.RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

原因:下载yolov5x.pt这个权重文件的时候没有下载完。

解决方法:可以自己手动下载,下载完即可。

6.运行这句话python setup.py build_ext --inplace出现了error: command 'D:\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2

解决方法:DOTA_devkit-master文件夹根目录的polyiou.cppNotepad打开,然后将编码改为UTF-8 BOM格式,再重新执行之前的代码就OK


记录的就暂时只有这些,如果有其它的问题,可以去开头的github链接中的issue中查找遇到的问题。


笔者也是小白一枚,有错误欢迎指正.

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值