参考博客:https://blog.csdn.net/ccbrid/article/details/79368639
在linux上
步骤
1.git clone cocoapi
github:
git clone https://github.com/pdollar/coco.git
gitee镜像(我用的这个):
git clone https://gitcode.net/mirrors/cocodataset/cocoapi.git
2.进入文件夹
cd coco
或者是
cd cocoapi
总之进入刚刚clone下来的文件夹
3.放入image和annotation
mkdir images
mkdir annotations
分别放官网https://cocodataset.org/#download下载的image和annotation文件夹(里面包含json),这里我只放了annotation就可以跑api里的demo了
我下载的数据如下:
解压后长这样:
我需要用的是captions
4.安装pythoncocoapi接口
cd PythonAPI
make
这里make报错
error: pycocotools/_mask.c: No such file or directory
解决参考:https://blog.csdn.net/ITtjt/article/details/122062849
解决方案:
pip install Cython
pip install pycocotools
将makefile文件中的python换成python3