前言.
最近因为项目的原因,要使用检测斜框的模型,就学习了一下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.cpp
用Notepad打开,然后将编码改为UTF-8 带BOM格式,再重新执行之前的代码就OK。
记录的就暂时只有这些,如果有其它的问题,可以去开头的github链接中的issue中查找遇到的问题。
笔者也是小白一枚,有错误欢迎指正.