COCO数据集

数据集文件夹介绍

1
2
3
4
5
6
7
COCO2017
├──annotations_trainval2017.zip
├──image_info_test2017.zip
├──stuff_annotations_trainval2017.zip
├──test2017.zip
├──train2017.zip
├──val2017.zip

下载地址
http://images.cocodataset.org/zips/train2017.zip
http://images.cocodataset.org/zips/val2017.zip
http://images.cocodataset.org/zips/test2017.zip
http://images.cocodataset.org/annotations/stuff_annotations_trainval2017.zip
http://images.cocodataset.org/annotations/panoptic_annotations_trainval2017.zip
http://images.cocodataset.org/zips/unlabeled2017.zip

文件内容

以下是每个文件内部的文件说明

1、annotations_trainval2017.zip

1
2
3
4
5
6
captions_train2017.json   # 看图说话
captions_val2017.json # 看图说话
instances_train2017.json # 目标检测
instances_val2017.json # 目标检测
person_keypoints_train2017.json # 目标上的关键点
person_keypoints_val2017.json # 目标上的关键点

2、image_info_test2017.zip

1
2
image_info_test2017.json
image_info_test-dev2017.json

3、stuff_annotations_trainval2017.zip

1
2
3
4
5
6
7
deprecated-challenge2017
├──train-ids.txt
└──val-ids.txt
stuff_train2017.json
stuff_train2017_pixelmaps.zip
stuff_val2017.json
stuff_val2017_pixelmaps.zip

4、test2017.zip

1
2
3
000000000001.jpg
000000000116.jpg
……

5、train2017.zip

1
2
3
000000000201.jpg
000000000316.jpg
……

6、val2017.zip

1
2
3
000000000401.jpg
000000000516.jpg
……

JSON文件解析

instances_train2017.json、instances_val2017.json文件解析
Object Instance这种格式的文件从头至尾按照顺序分为以下段落:

1
2
3
4
5
6
7
{
"info": info,
"licenses": [license],
"images": [image],
"annotations": [annotation],
"categories": [category]
}

你打开这两个文件,虽然内容很多,但从文件开始到结尾按照顺序就是这5段。在不同的JSON文件中info、licenses、images是一样的。不同的是annotation和category这两种结构体,他们在不同类型的JSON文件中是不一样的。

images数组元素的数量等同于划入训练集(或者测试集)的图片的数量;

annotations数组元素的数量等同于训练集(或者测试集)中bounding box的数量;

categories数组元素的数量为80(2017年);

info字段

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
info{
"year": int,
"version": str,
"description": str,
"contributor": str,
"url": str,
"date_created": datetime,
}
# info的一个实例
"info":{
"description":"This is stable 1.0 version of the 2014 MS COCO dataset.",
"url":"http:\/\/mscoco.org",
"version":"1.0","year":2014,
"contributor":"Microsoft COCO group",
"date_created":"2015-01-27 09:11:52.357475"
},

images字段

Images是包含多个image实例的数组,对于一个image类型的实例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
image{
"id": int,
"width": int,
"height": int,
"file_name": str,
"license": int,
"flickr_url": str,
"coco_url": str,
"date_captured": datetime,
}
# images实例
{
"license":3,
"file_name":"COCO_val2014_000000391895.jpg",
"coco_url":"http:\/\/mscoco.org\/images\/391895",
"height":360,"width":640,"date_captured":"2013-11-14 11:18:45",
"flickr_url":"http:\/\/farm9.staticflickr.com\/8186\/8119368305_4e622c8349_z.jpg",
"id":391895
},

licenses字段

licenses是包含多个license实例的数组,对于一个license类型的实例

1
2
3
4
5
6
7
8
9
10
11
license{
"id": int,
"name": str,
"url": str,
}
licenses实例
{
"url":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/2.0\/",
"id":1,
"name":"Attribution-NonCommercial-ShareAlike License"
},

annotations字段

annotations字段是包含多个annotation实例的一个数组,annotation类型本身又包含了一系列的字段,如这个目标的category id和segmentation mask。segmentation格式取决于这个实例是一个单个的对象(即iscrowd=0,将使用polygons格式)还是一组对象(即iscrowd=1,将使用RLE格式)。如下所示:

1
2
3
4
5
6
7
8
9
annotation{
"id": int,
"image_id": int,
"category_id": int,
"segmentation": RLE or [polygon],
"area": float,
"bbox": [x,y,width,height],
"iscrowd": 0 or 1,
}

注意,单个的对象(iscrowd=0)可能需要多个polygon来表示,比如这个对象在图像中被挡住了。而iscrowd=1时(将标注一组对象,比如一群人)的segmentation使用的就是RLE格式。

注意啊,只要是iscrowd=0那么segmentation就是polygon格式;只要iscrowd=1那么segmentation就是RLE格式。另外,每个对象(不管是iscrowd=0还是iscrowd=1)都会有一个矩形框bbox ,矩形框左上角的坐标和矩形框的长宽会以数组的形式提供,数组第一个元素就是左上角的横坐标值。

area是area of encoded masks,是标注区域的面积。如果是矩形框,那就是高乘宽;如果是polygon或者RLE,那就复杂点。

最后,annotation结构中的categories字段存储的是当前对象所属的category的id,以及所属的supercategory的name。

下面是从instances_val2017.json文件中摘出的一个annotation的实例,这里的segmentation就是polygon格式:

1
2
3
4
5
6
7
8
9
{
"segmentation": [[510.66,423.01,511.72,420.03,510.45......]],
"area": 702.1057499999998,
"iscrowd": 0,
"image_id": 289343,
"bbox": [473.07,395.93,38.65,28.67],
"category_id": 18,
"id": 1768
},

实例文档

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
{
"info": {
"description": "COCO 2017 Dataset",
"url": "http://cocodataset.org",
"version": "1.0",
"year": 2017,
"contributor": "COCO Consortium",
"date_created": "2017/09/01"
},
"licenses": [{
"url": "http://creativecommons.org/licenses/by-nc-sa/2.0/",
"id": 1,
"name": "Attribution-NonCommercial-ShareAlike License"
},
{
"url": "http://creativecommons.org/licenses/by-nc/2.0/",
"id": 2,
"name": "Attribution-NonCommercial License"
},
{
"url": "http://creativecommons.org/licenses/by-nc-nd/2.0/",
"id": 3,
"name": "Attribution-NonCommercial-NoDerivs License"
},
{
"url": "http://creativecommons.org/licenses/by/2.0/",
"id": 4,
"name": "Attribution License"
},
{
"url": "http://creativecommons.org/licenses/by-sa/2.0/",
"id": 5,
"name": "Attribution-ShareAlike License"
},
{
"url": "http://creativecommons.org/licenses/by-nd/2.0/",
"id": 6,
"name": "Attribution-NoDerivs License"
},
{
"url": "http://flickr.com/commons/usage/",
"id": 7,
"name": "No known copyright restrictions"
},
{
"url": "http://www.usa.gov/copyright.shtml",
"id": 8,
"name": "United States Government Work"
}
],
"images": [{
"license": 4,
"file_name": "000000397133.jpg",
"coco_url": "http://images.cocodataset.org/val2017/000000397133.jpg",
"height": 427,
"width": 640,
"date_captured": "2013-11-14 17:02:52",
"flickr_url": "http://farm7.staticflickr.com/6116/6255196340_da26cf2c9e_z.jpg",
"id": 397133
},
{
"license": 1,
"file_name": "000000158227.jpg",
"coco_url": "http://images.cocodataset.org/val2017/000000158227.jpg",
"height": 357,
"width": 500,
"date_captured": "2013-11-22 23:05:30",
"flickr_url": "http://farm1.staticflickr.com/210/495201463_3d6b548c08_z.jpg",
"id": 158227
},
{
"license": 1,
"file_name": "000000407646.jpg",
"coco_url": "http://images.cocodataset.org/val2017/000000407646.jpg",
"height": 400,
"width": 500,
"date_captured": "2013-11-23 03:58:53",
"flickr_url": "http://farm4.staticflickr.com/3110/2855627782_17b93a684e_z.jpg",
"id": 407646
},
],
"annotations": [{
"segmentation": [
[510.66, 510.03, 423.01, 510.45, 423.01]
],
"area": 702.1057499999998,
"iscrowd": 0,
"image_id": 289343,
"bbox": [473.07, 395.93, 38.65, 28.67],
"category_id": 18,
"id": 1768
},
{
"segmentation": [
[289.749, 228.64, 444.27, 291.88, 443.74]
],
"area": 27718.476299999995,
"iscrowd": 0,
"image_id": 61471,
"bbox": [272.1, 200.23, 151.97, 279.77],
"category_id": 18,
"id": 1773
},
{
"segmentation": {
"counts": [272, 2, 4, , 221, 16, 228, 8, 10250],
"size": [240, 320]
},
"area": 18419,
"iscrowd": 1,
"image_id": 448263,
"bbox": [1, 0, 276, 122],
"category_id": 1,
"id": 900100448263
},
{
"segmentation": {
"counts": [8214, 6, 6634, 4, 99294],
"size": [640, 549]
},
"area": 962,
"iscrowd": 1,
"image_id": 374545,
"bbox": [12, 524, 381, 33],
"category_id": 1,
"id": 900100374545
},
{
"segmentation": {
"counts": [66916, 6, 58785, 8, 588, 1, 114303],
"size": [594, 640]
},
"area": 6197,
"iscrowd": 1,
"image_id": 284445,
"bbox": [112, 322, 335, 94],
"category_id": 1,
"id": 900100284445
},
{"supercategory": "person","id": 1,"name": "person"},
{"supercategory": "vehicle","id": 2,"name": "bicycle"},
{"supercategory": "vehicle","id": 3,"name": "car"},
{"supercategory": "vehicle","id": 4,"name": "motorcycle"},
{"supercategory": "vehicle","id": 5,"name": "airplane"},
{"supercategory": "vehicle","id": 6,"name": "bus"},
{"supercategory": "vehicle","id": 7,"name": "train"},
{"supercategory": "vehicle","id": 8,"name": "truck"},
{"supercategory": "vehicle","id": 9,"name": "boat"},
{"supercategory": "outdoor","id": 10,"name": "traffic light"},
{"supercategory": "outdoor","id": 11,"name": "fire hydrant"},
{"supercategory": "outdoor","id": 13,"name": "stop sign"},
{"supercategory": "outdoor","id": 14,"name": "parking meter"},
{"supercategory": "outdoor","id": 15,"name": "bench"},
{"supercategory": "animal","id": 16,"name": "bird"},
{"supercategory": "animal","id": 17,"name": "cat"},
{"supercategory": "animal","id": 18,"name": "dog"},
{"supercategory": "animal","id": 19,"name": "horse"},
{"supercategory": "animal","id": 20,"name": "sheep"},
{"supercategory": "animal","id": 21,"name": "cow"},
{"supercategory": "animal","id": 22,"name": "elephant"},
{"supercategory": "animal","id": 23,"name": "bear"},
{"supercategory": "animal","id": 24,"name": "zebra"},
{"supercategory": "animal","id": 25,"name": "giraffe"},
{"supercategory": "accessory","id": 27,"name": "backpack"},
{"supercategory": "accessory","id": 28,"name": "umbrella"},
{"supercategory": "accessory","id": 31,"name": "handbag"},
{"supercategory": "accessory","id": 32,"name": "tie"},
{"supercategory": "accessory","id": 33,"name": "suitcase"},
{"supercategory": "sports","id": 34,"name": "frisbee"},
{"supercategory": "sports","id": 35,"name": "skis"},
{"supercategory": "sports","id": 36,"name": "snowboard"},
{"supercategory": "sports","id": 37,"name": "sports ball"},
{"supercategory": "sports","id": 38,"name": "kite"},
{"supercategory": "sports","id": 39,"name": "baseball bat"},
{"supercategory": "sports","id": 40,"name": "baseball glove"},
{"supercategory": "sports","id": 41,"name": "skateboard"},
{"supercategory": "sports","id": 42,"name": "surfboard"},
{"supercategory": "sports","id": 43,"name": "tennis racket"},
{"supercategory": "kitchen","id": 44,"name": "bottle"},
{"supercategory": "kitchen","id": 46,"name": "wine glass"},
{"supercategory": "kitchen","id": 47,"name": "cup"},
{"supercategory": "kitchen","id": 48,"name": "fork"},
{"supercategory": "kitchen","id": 49,"name": "knife"},
{"supercategory": "kitchen","id": 50,"name": "spoon"},
{"supercategory": "kitchen","id": 51,"name": "bowl"},
{"supercategory": "food","id": 52,"name": "banana"},
{"supercategory": "food","id": 53,"name": "apple"},
{"supercategory": "food","id": 54,"name": "sandwich"},
{"supercategory": "food","id": 55,"name": "orange"},
{"supercategory": "food","id": 56,"name": "broccoli"},
{"supercategory": "food","id": 57,"name": "carrot"},
{"supercategory": "food","id": 58,"name": "hot dog"},
{"supercategory": "food","id": 59,"name": "pizza"},
{"supercategory": "food","id": 60,"name": "donut"},
{"supercategory": "food","id": 61,"name": "cake"},
{"supercategory": "furniture","id": 62,"name": "chair"},
{"supercategory": "furniture","id": 63,"name": "couch"},
{"supercategory": "furniture","id": 64,"name": "potted plant"},
{"supercategory": "furniture","id": 65,"name": "bed"},
{"supercategory": "furniture","id": 67,"name": "dining table"},
{"supercategory": "furniture","id": 70,"name": "toilet"},
{"supercategory": "electronic","id": 72,"name": "tv"},
{"supercategory": "electronic","id": 73,"name": "laptop"},
{"supercategory": "electronic","id": 74,"name": "mouse"},
{"supercategory": "electronic","id": 75,"name": "remote"},
{"supercategory": "electronic","id": 76,"name": "keyboard"},
{"supercategory": "electronic","id": 77,"name": "cell phone"},
{"supercategory": "appliance","id": 78,"name": "microwave"},
{"supercategory": "appliance","id": 79,"name": "oven"},
{"supercategory": "appliance","id": 80,"name": "toaster"},
{"supercategory": "appliance","id": 81,"name": "sink"},
{"supercategory": "appliance","id": 82,"name": "refrigerator"},
{"supercategory": "indoor","id": 84,"name": "book"},
{"supercategory": "indoor","id": 85,"name": "clock"},
{"supercategory": "indoor","id": 86,"name": "vase"},
{"supercategory": "indoor","id": 87,"name": "scissors"},
{"supercategory": "indoor","id": 88,"name": "teddy bear"},
{"supercategory": "indoor","id": 89,"name": "hair drier"},
{"supercategory": "indoor","id": 90,"name": "toothbrush"}
]
}

帮助文档

COCO数据集的标注格式


微信:宏沉一笑
公众号:漫步之行

签名:Smile every day
名字:宏沉一笑
邮箱:whghcyx@outlook.com
个人网站:https://whg555.github.io



转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 whghcyx@outlook.com

文章标题:COCO数据集

文章字数:3.3k

本文作者:宏沉一笑

发布时间:2020-02-04, 14:48:14

最后更新:2024-03-21, 12:53:35

原始链接:https://whghcyx.gitee.io/2020/02/04/AI-2020-2-4-COCO%E6%95%B0%E6%8D%AE%E9%9B%86/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

目录
×

喜欢就点赞,疼爱就打赏