Yolov6解决常见报错(1)TypeError numpy.float64 object cannot be interpreted as an index
这几天偶然看见Yolov6出来,迫不及待的试了一下,结果看见网上评论说bug太多了,我作为使用者,想着积极做出贡献,把一些我解决的bug分享一下,方便大家也能看到顺便解决。
先看报错
Training completed in 0.082 hours.
Traceback (most recent call last):
File "tools/train.py", line 92, in
main(args)
File "tools/train.py", line 82, in main
trainer.train()
File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/multi-gpu-4-tesla-m60/code/Users/zhanghe/cv-safety-detection/YOLOv6/yolov6/core/engine.py", line 70, in train
self.train_in_loop()
File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/multi-gpu-4-tesla-m60/code/Users/zhanghe/cv-safety-detection/YOLOv6/yolov6/core/engine.py", line 89, in train_in_loop
self.eval_and_save()
File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/multi-gpu-4-tesla-m60/code/Users/zhanghe/cv-safety-detection/YOLOv6/yolov6/core/engine.py", line 115, in eval_and_save
self.eval_model()
File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/multi-gpu-4-tesla-m60/code/Users/zhanghe/cv-safety-detection/YOLOv6/yolov6/core/engine.py", line 134, in eval_model
results = eval.run(self.data_dict,
File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/multi-gpu-4-tesla-m60/code/Users/zhanghe/cv-safety-detection/YOLOv6/tools/eval.py", line 83, in run
eval_result = val.eval_model(pred_result, model, dataloader, task)
File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/multi-gpu-4-tesla-m60/code/Users/zhanghe/cv-safety-detection/YOLOv6/yolov6/core/evaler.py", line 128, in eval_model
cocoEval = COCOeval(anno, pred, 'bbox')
File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/pycocotools/cocoeval.py", line 76, in init
self.params = Params(iouType=iouType) # parameters
File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/pycocotools/cocoeval.py", line 527, in init
self.setDetParams()
File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/pycocotools/cocoeval.py", line 507, in setDetParams
self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True)
File "<array_function internals>", line 5, in linspace
File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/numpy/core/function_base.py", line 113, in linspace
num = operator.index(num)
TypeError: 'numpy.float64' object cannot be interpreted as an integer
如果大家和我一样是这样的报错,在第一轮epoch结束的时候的报错,num = operator.index(num)报错。
刚开始去网上找原因,发现很多说因为numpy的版本太高了,需要转低版本,但是我转了低版本也并没有解决问题,没有办法,只好去看代码来找原因,看到pycocotools/cocoeval.py这个文件里的报错。
大家先别急,我又去网上找这个的报错,结果终于找到了,是因为在numpy 1.11.0之后的版本只支持int类型的输入参数,而源码使用的浮点数。在代码的503行的setDetParams函数,
def setDetParams(self):self.imgIds = []self.catIds = []np.arange causes trouble. the data point on arange is slightly larger than the true valueself.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True)self.recThrs = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True)self.maxDets = [1, 10, 100]self.areaRng = [[0 ** 2, 1e5 ** 2], [0 ** 2, 32 ** 2], [32 ** 2, 96 ** 2], [96 ** 2, 1e5 ** 2]]self.areaRngLbl = ['all', 'small', 'medium', 'large']self.useCats = 1
其中np.linspace使用的是浮点数,生成0.05步长,0.5~0.95的数组。
使用numpy.arange函数代替
def setDetParams(self):self.imgIds = []self.catIds = []# np.arange causes trouble. the data point on arange is slightly larger than the true value# self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True)# self.recThrs = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True)self.iouThrs = np.arange(0.5, 0.97, 0.05)self.recThrs = np.arange(0., 1.0001, 0.01)self.maxDets = [1, 10, 100]self.areaRng = [[0 ** 2, 1e5 ** 2], [0 ** 2, 32 ** 2], [32 ** 2, 96 ** 2], [96 ** 2, 1e5 ** 2]]self.areaRngLbl = ['all', 'small', 'medium', 'large']self.useCats = 1
另外529行的setKpParams也要修改
def setKpParams(self):self.imgIds = []self.catIds = []# np.arange causes trouble. the data point on arange is slightly larger than the true value# self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True)# self.recThrs = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True)self.iouThrs = np.arange(0.5, 0.97, 0.05)self.recThrs = np.arange(0., 1.0001, 0.01)self.maxDets = [20]self.areaRng = [[0 ** 2, 1e5 ** 2], [32 ** 2, 96 ** 2], [96 ** 2, 1e5 ** 2]]self.areaRngLbl = ['all', 'medium', 'large']self.useCats = 1
以上是由schmiloo的文章帮我解决了这个问题,非常感谢大神
文章连接:
TypeError numpy.float64 object cannot be interpreted as an index 完美解决方法_schmiloo的博客-CSDN博客
Yolov6解决常见报错(1)TypeError numpy.float64 object cannot be interpreted as an index相关推荐
- frcnn系列错误: TypeError: 'numpy.float64' object cannot be interpreted as an index 的解决方案
1.TypeError: 'numpy.float64' object cannot be interpreted as an index 的解决方案 看了很多博客都说要调整numpy版本到1.11. ...
- 训练数据出现TypeError: 'numpy.float64' object cannot be interpreted as an integer错误
问题背景: 用tensorflow训练自己的数据的时候,训练一段时间后,出现TypeError: 'numpy.float64' object cannot be interpreted as an ...
- TWINCAT3中使用FIFO收集三轴的位置信息,XML文件的生成,解决常见报错
TWINCAT3中使用FIFO收集三轴的位置信息,XML文件的生成,解决常见报错 1.首先到官网下载程序 很多时候我们用twincat不具备硬件条件,需要用到虚轴进行测试,但是对于初学者来说,用twi ...
- 'numpy.float64' object cannot be interpreted as an integer
'numpy.float64' object cannot be interpreted as an integer fp=open(filename,'rb') blk_size = prod(di ...
- 常见报错——Uncaught TypeError: document.getElementsByClassName(...).addEventListener is not a function
在进行原生的前端开发的时候遇到的问题: Uncaught TypeError: document.getElementsByClassName(...).addEventListener is not ...
- VMware虚拟机安装Win11教程(解决常见报错)
前言 今天闲来无事,就想着装一下最新版的win11玩一下,然后来来去去还是折腾了一些时间,有遇到一些错误不过最好都找到了解决办法,下面我就分享一下VMware虚拟机安装win11的详细步骤. VMwa ...
- 常见报错——Uncaught TypeError: document.getElementsByClassName(...).addEventListener is not a function...
这是因为选择器没有正确选择元素对象 document.getElementsByClassName(...)捕捉到的是该类名元素的数组 正确的访问方式应该是: document.getElements ...
- 《python计算机视觉》关于‘numpy.float64‘ object cannot be interpreted as an integer错误的解决办法
在<python计算机视觉>这本书的学习中,按照书中的代码敲完运行会发现这个报错: 运行代码如下: # Warp_Triangle_Image01.pyfrom pylab import ...
- ‘numpy.float64‘ object cannot be interpreted as an integer
能运行的代码: import numpy as npaaa=np.linspace(0.2, 1, 9)print(aaa) 报错的代码: import numpy as npccc=np.round ...
最新文章
- 使用SharePoint Online PowerShell cmdlet有哪些好处?
- Linux 之一 基本命令
- 使用Cloud Application Programming模型开发OData的一个实际例子
- oracle怎么优化动态sql语句,oracle动态sql语句处理
- mysql数据库安全机制研究意义_MySQL数据库的安全机制
- dnn神经网络 缺点_抄近路神经网络如何因找捷径而犯错
- 用onSaveInstanceState()方法保存Activity状态
- 虚拟内存与物理内存与内存碎片-杂谈
- PMSM FOC控制 Matlab/Simulink仿真之反Clark变换
- 新员工月度计划制定心得
- Terms-level Query之Fuzzy Query
- 蚂蚁笔记(leanote)搭建
- 区块链定制开发用什么编程语言?
- 模块:导入和使用标准模块,第三方模块
- 分身竞选总统?法国总统竞选这么干! 全息3d网
- 简单交错序列前N项和
- java毕业生设计学生信息管理系统计算机源码+系统+mysql+调试部署+lw
- 点点鼠标在线绘制GO/KEGG富集分析泡泡图
- 华为程序员,985本科36岁,被公司解约:中年人路在何方?
- 数据结构与算法(青岛大学-王卓老师)——学习笔记(第2周)