Ubuntu安装pycocotools

版权声明:本文博主原创,有需要请联系我。 https://blog.csdn.net/myGFZ/article/details/80177419

导言

最近在实现Mask R-CNN,为了实现在MS COCO数据集上训练和测试数据,需要安装pycocotools。记录安装过程和遇到的问题。

一、MS coco数据集

Microsoft COCO 数据集(也称为Ms coco数据集):微软团队的,一个可以用来对图像recognition+segmentation+captioning 的数据集。
该数据集主要解决3个问题:目标检测,目标之间的上下文关系,目标的2维上的精确定位。

二、安装pycocotools

1、首先在github上直接下载zip文件到本地:
https://github.com/cocodataset/cocoapi

2、提取到任意文件夹,在终端里cd到cocoapi-master/PythonAPI目录下,直接使用make指令,就执行安装了。例如我:

lab2408@lab2408:~/gucheng/cocoapi-master/PythonAPI$ make

三、问题记录及解决

1、

大意如下:

x86_64-linux-gnu-gcc: error: pycocotools/_mask.c: 没有那个文件或目录
x86_64-linux-gnu-gcc: fatal error: no input files
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Makefile:3: recipe for target 'all' failed
make: *** [all] Error 1

解决方案:
因为我时基于python3.5调用cocoAPI,所以应该安装cython库。
cython库是一个用来快速生成Python扩展模块(extention module)的工具,其主要目的是简化python调用c语言程序的繁琐封装过程,提高python代码执行速度(C语言的执行速度比python快)。

cython安装方法:

sudo install cython

安装完cython之后,修改PythonAPI文件下下Maefile文件中所有的python为python3。然后再重新执行make指令。

参考资料

1、https://github.com/cocodataset/cocoapi
2、cython的安装
3、https://blog.csdn.net/weixin_35653315/article/details/75314710
4、MS coco数据集下载及踩过得坑

猜你喜欢

转载自blog.csdn.net/myGFZ/article/details/80177419