COCO Detection Challenge

Introduction

COCO的全称是Common Object in Context, 是 MicroSoft 赞助的CV挑战, 包含 Detections, Captions, Keypoints 三个Challenge, 及相应的数据集.
接下来根据coco 2016介绍它的Detection Challenge.
值得指出的是, coco2016 detection与coco2015一模一样.

Dataset下载

数据集由train/val/tests三部分构成, 总共包含超过20,000张标注图片, 80个类别. 所有的object instance都有bounding box 和segmentation groundtruth, 既可用于detection, 又可用于segmentation.
这里写图片描述
下载地址 http://mscoco.org/dataset/#download

  • 2014 Testing Images在Captioning Challenge中使用
  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
你可以使用一些工具和代码来将VOC格式的数据转换为COCO格式,以便在mmdetection中使用。以下是一种可能的方法: 1. 首先,确保你已经安装了`mmcv`和`mmdet`库。你可以使用以下命令安装它们: ``` pip install mmcv-full mmdet ``` 2. 下载并解压VOC数据集,并将其组织为以下结构: ``` VOCdevkit/ ├── VOC2007 │ ├── Annotations │ ├── ImageSets │ └── JPEGImages └── VOC2012 ├── Annotations ├── ImageSets └── JPEGImages ``` 3. 创建一个Python脚本,例如`voc2coco.py`,并使用以下代码来进行VOC到COCO格式转换: ```python import os import json from xml.etree.ElementTree import Element, SubElement, tostring from xml.dom.minidom import parseString def parse_voc_annotation(ann_dir, img_dir, labels=[]): # 读取VOC标注文件和图像文件夹 ann_files = sorted(os.listdir(ann_dir)) img_files = sorted(os.listdir(img_dir)) assert len(ann_files) == len(img_files), "Number of annotation files doesn't match number of image files" # 构建COCO格式标注数据结构 coco_data = { "images": [], "annotations": [], "categories": [] } category_id = 0 for i, ann_file in enumerate(ann_files): img_file = img_files[i] img_id = i + 1 # 解析VOC标注文件 ann_path = os.path.join(ann_dir, ann_file) tree = parseString(open(ann_path).read()) root = tree.documentElement # 获取图像信息 img_width = int(root.getElementsByTagName("width")[0].childNodes[0].data) img_height = int(root.getElementsByTagName("height")[0].childNodes[0].data) img_name = img_file.split(".")[0] # 添加图像信息到coco_data["images"] coco_data["images"].append({ "file_name": img_file, "height": img_height, "width": img_width, "id": img_id }) # 解析VOC标注信息 objects = root.getElementsByTagName("object") for obj in objects: name = obj.getElementsByTagName("name")[0].childNodes[0].data if name not in labels: labels.append(name) category_id = labels.index(name) + 1 bbox = obj.getElementsByTagName("bndbox")[0] xmin = int(bbox.getElementsByTagName("xmin")[0].childNodes[0].data) ymin = int(bbox.getElementsByTagName("ymin")[0].childNodes[0].data) xmax = int(bbox.getElementsByTagName("xmax")[0].childNodes[0].data) ymax = int(bbox.getElementsByTagName("ymax")[0].childNodes[0].data) width = xmax - xmin height = ymax - ymin # 添加标注信息到coco_data["annotations"] coco_data["annotations"].append({ "image_id": img_id, "category_id": category_id, "bbox": [xmin, ymin, width, height], "area": width * height, "iscrowd": 0, "id": len(coco_data["annotations"]) + 1 }) # 构建coco_data["categories"] for i, label in enumerate(labels): coco_data["categories"].append({ "id": i + 1, "name": label, "supercategory": "object" }) return coco_data if __name__ == '__main__': ann_dir = 'VOCdevkit/VOC2007/Annotations' img_dir = 'VOCdevkit/VOC2007/JPEGImages' labels = [] coco_data = parse_voc_annotation(ann_dir, img_dir, labels) # 保存为COCO格式的JSON文件 with open('annotations.json', 'w') as f: json.dump(coco_data, f) ``` 4. 运行`voc2coco.py`脚本,它将生成一个名为`annotations.json`的COCO格式标注文件。 现在,你可以使用这个生成的COCO格式的标注文件在mmdetection中进行训练或评估。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值