使用COCOAPI操作COCO数据集 遇到的问题 TypeError: 'numpy.float64' object cannot be interpreted

使用COCOAPI操作COCO数据集 遇到的问题 TypeError: ‘numpy.float64’ object cannot be interpreted as an integer

flyfish

详细提示是

line 518
self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True)
File "/media/ubuntu/data/env/lib/python3.6/site-packages/numpy/core/function_base.py", line 121, in 
TypeError: 'numpy.float64' object cannot be interpreted as an integer

也就是出错在
self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True)
这句

可以更改代码,不止有一处

self.iouThrs = np.linspace(.5, 0.95, int(np.round((0.95 - .5) / .05)) + 1, endpoint=True)
self.recThrs = np.linspace(.0, 1.00, int(np.round((1.00 - .0) / .01)) + 1, endpoint=True)

因为官网已修复这个bug,可以使用新的代码重新安装
使用源码安装 pycocotools
1 确保python命令行执行的是python3

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150

最后的100和150是priority

Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

2 下载源码

git clone https://github.com/cocodataset/cocoapi.git

3 安装
切换到 cocoapi\PythonAPI目录

make -j8
python setup.py install

或者按照下面的执行

# To compile and install locally run 
python setup.py build_ext --inplace
# To install library to Python site-packages run 
python setup.py build_ext install

你可能感兴趣的:(使用COCOAPI操作COCO数据集 遇到的问题 TypeError: 'numpy.float64' object cannot be interpreted)