AttributeError: ‘COCO‘ object has no attribute ‘get_cat_ids‘

实验环境:Ubuntu 16.04

  • python 3.7.7
  • cuda 10.1
  • pytorch 1.5.0
  • torchvision 0.6.0
  • mmcv 1.0.4

因为跑的代码里面用到了mmdet库,出现了以上问题,查询后发现是因为mmdetection用到了pycocotools,本来接口是pycocotools.coco.getCatds,但是mmdetection又在外包了一层,变成了get cat ids,而pycocotools.coco又没有这个成员函数,导致出错。(参考https://blog.csdn.net/happyday_d/article/details/107388511)
github上的解决办法是重装pycocotools,通过命令:

pip install "git+https://github.com/open-mmlab/cocoapi.git#subdirectory=pycocotools"

但是!!实验室的服务器没法访问外网,所以我直接在github上进入 GitHub - open-mmlab/cocoapi: COCO API - Dataset @ http://cocodataset.org/,把整个项目download下来传到服务器上,然后在实验环境下进入cocoapi-api/pycocotools这个目录,然后运行

make

然后!!就又出现了错误
gcc: error: ../common/maskApi.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
error: command 'gcc' failed with exit status 1
Makefile:3: recipe for target 'all' failed
make: *** [all] Error 1
以下是在github上找到的解决办法:
1.安装cython

pip3 install cython

2.修改makefile文件中的python 为python3或者环境对应版本

其实试了前两种方法都没成功,最后!!我试了这个天才办法:

3.卸载cython,安装cython==0.29.33

pip uninstall cython
pip install cython==0.29.33

重新make即可。

  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值