首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >未定义名称'coco‘

未定义名称'coco‘
EN

Stack Overflow用户
提问于 2019-08-27 03:27:10
回答 1查看 1.4K关注 0票数 0

我曾尝试克隆coco API以从coco数据集中下载特定的类,但当我在Google Colaboratory中运行代码时,它给出了这个错误:name 'coco' is not defined

代码语言:javascript
运行
复制
!git clone https://github.com/philferriere/cocoapi
#display COCO categories
cats = coco.loadCats(coco.getCatIds())
nms=[cat['name'] for cat in cats]
print('COCO categories: \n{}\n'.format(' '.join(nms)))

# get all images containing given categories (I'm selecting the "bird")
catIds = coco.getCatIds(catNms=['bird']);
imgIds = coco.getImgIds(catIds=catIds);
EN

回答 1

Stack Overflow用户

发布于 2019-08-27 05:26:40

我认为这来自于https://github.com/philferriere/cocoapi/blob/master/PythonAPI/demos/pycocoDemo.ipynb中的示例

并且您需要复制更多的行:

代码语言:javascript
运行
复制
from pycocotools.coco import COCO
# ... skipped some lines here
# initialize COCO api for instance annotations
coco=COCO(annFile)
cats = coco.loadCats(coco.getCatIds())
nms=[cat['name'] for cat in cats]
print('COCO categories: \n{}\n'.format(' '.join(nms)))

# get all images containing given categories (I'm selecting the "bird")
catIds = coco.getCatIds(catNms=['bird']);
imgIds = coco.getImgIds(catIds=catIds);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57663824

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档