当前位置:   article > 正文

跑yolov5-obb时的错误_yolov5的代码中的np.int在最新版本的numpy中废止了怎么办

yolov5的代码中的np.int在最新版本的numpy中废止了怎么办

前言.

最近因为项目的原因,要使用检测斜框的模型,就学习了一下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中查找遇到的问题。


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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/850475
推荐阅读
相关标签
  

闽ICP备14008679号