MS COCO数据集介绍
MS COCO数据集介绍
MS COCO全称是Microsoft Common Objects in Context,是由微软开发维护的大型图像数据集,包括不同检测任务:
- Object Detection([主要处理人、车、大象等])
- DensePose(姿态密度检测)
- Keypoints(关键点检测)
- Stuff([主要处理草、墙、天等])
- Panoptic(场景分割)
- Captions(字幕标注)
MS COCO数据格式
MS COCO使用JSON存储标注数据
所有MS COCO的标注数据第一层都至少包含以下四个对象,不同检测任务的annotations
不同且部分检测任务还包含一个categories
(JSON第一层即包含五个对象)
{"info": info, "images": [image], "annotations": [annotation], "licenses": [license],
}
这里以关键点检测的验证集为例,查看它的json内容
import json
json_path = r"D:\Python\Jupyter\pytorch\yolov8\MS COCO\annotations\person_keypoints_val2017.json"
json_labels = json.load(open(json_path, "r"))
第一层结构如下,包含info
、licenses
、images
、annotations
、categories
,共五个对象
info
保存数据集的信息
licenses
保存数据集的许可协议
images
保存每张图片的信息,如图片文件名、宽、高等信息
annotations
保存标注信息:
参数 | 参数含义 |
---|---|
segmentation | 保存polygon数据 |
num_keypoints | 表示给定对象的标记关键点数量(对象集合或小对象的num_keypoints 值为0) |
area | 保存目标面积 |
iscrowd | 值为0表示单个对象,值为1表示对象集合 |
keypoints | 是一个长度为3k的数组,其中k是定义的关键点类别总数(在MS COCO中k=17)。每个关键点按顺序依次存储横坐标x,纵坐标y和关键点可见性v。v=0:未标记(此情况下,x=y=0),v=1:标记但不可见,v=2:标记且可见。如果关键点位于上面segmentation 的框内,则该关键点被视为可见 |
image_id | 表示MS COCO数据集的图片id |
bbox | 保存边界框(bounding box)左上角点的横纵坐标、宽度和高度 |
category_id | 表示类别id |
id | 表示label的id,也就是每一个label(人、等车实例对应的bbox)都有一个和它一一对应的id。一个image_id 可以对应多个id (一张图片上有多个label),而一个id 只能对应一个image_id |
categories
保存类别信息:
关键点检测的JSON结构如下:
{"info" : {"year" : int, "version" : str, "description" : str, "contributor" : str, "url" : str, "date_created" : datetime,},"licenses" : {"id" : int, "name" : str, "url" : str,},"images" : {"id" : int, "width" : int, "height" : int, "file_name" : str, "license" : int, "flickr_url" : str, "coco_url" : str, "date_captured" : datetime,}, "annotations" : {"segmentation" : RLE or [polygon],"num_keypoints" : int,"area" : float,"iscrowd" : 0 or 1,"keypoints" : [x1,y1,v1,...],"image_id" : int,"bbox" : [x,y,width,height],"category_id" : int,"id" : int,}, "categories" : {"supercategory" : str,"id" : int,"name" : str,"keypoints" : [str], "skeleton" : [edge], },
}
参考资料
- https://cocodataset.org/#format-data
- MS COCO数据集介绍以及pycocotools简单使用
- MSCOCO api详解 —— Keypoints
- 目标检测数据集MSCOCO详解