COCO标注格式

详细解说可以看这个视频:COCO File Format

COCO的标注文件分为如下5个部分:

annotation = {
    'info': {},
    'licenses': [],
    'images': [],
    'annotations': [],
    'categories': []
}

annotation[‘info’]

info部分记录了整个数据集的名称、URL、版本、时间等基本信息。不包含具体的数据信息。例如:

annotation['info'] = {
	'description': 'COCO 2017 Dataset',
	'url': 'http://cocodataset.org',
	'version': '1.0',
	'year': 2017,
	'contributor': 'COCO Consortium',
	'date_created': '2017/09/01'
}

annotation[‘licenses’]

licenses部分记录了数据集中的数据遵循了哪些license。不包含具体的数据信息。例如:

annotation['licenses'] = [
	{
		'url': '',
		'id': 1,
		'name': 
	},
	{
		'url': '',
		'id': 2,
		'name': 
	},
	{
		'url': '',
		'id': 3,
		'name': 
	}
]

annotations[‘images’]

images部分记录了每幅图像的基础信息,包括遵循的license、文件名、COCO URL、宽高、采集时间、flickr URL、id。通过id可以在后面的annotation部分查询到该图像的标注信息。

annotations['images'] = [
	{
		'license': 1,
		'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
	},
	...
]

annotation[‘annotations’]

annotations部分记录了标注信息,包括segmentation、bbox、面积(area)、是否为群体(iscrowd)、image_id、类别(category_id)、instance id(id)。
注意,这里的’image_id’对应的是前面images部分的’id’,而这里的’id’指的是每个instance的’id’。
每个dict记录的是一个instance的标注,而不是整幅图像。

annotation['annotations'] = [
	{
		'segmentation': []
		'area': 702.1057
		'iscrowd': 0
		'image_id': 289343
		'bbox': [473.07, 395.93, 38.65, 28.67]
		'category_id': 18
		'id': 1768
	},
	{
		'segmentation':
		'area':
		'iscrowd':
		'image_id':
		'bbox':
		'category_id':
		'id':
	},
	...
]

详解:
segmentation
该部分标注的是分割任务所需的mask。
注意,一个segmentation中可能包含不止一个mask,原因是一个instance可能被遮挡,从而对应多个mask(例如大象被树干挡住,从而变成了两部分)。
mask有两种标注方式。一种方式是多边形标注(polygon),其中每一个list都对应一个多边形,形式如下:

{
...
	'segmentation': [
		[x00, y00, x01, y01,..., x0n, y0n],
		[x10, y10, x11, y11,..., x1n, y1n],
		...
	]
...
}

另一种方式是run-length encoding(RLE),通常用于标注iscrowd为1的instance,形式如下(其中’counts’的具体解释请看最上面的视频链接):

{
...
	'segmentation': {
		'size': [height, width],
		'counts': [b0, f0, b1, f1, ...]
	}
...
}

bbox
bbox标注的是instance的包围框(bounding box),其格式是:[x, y, width, height]
area
mask覆盖的面积(像素总数),可用来筛选不同面积的instance。
image_id
对应于前面’images’部分的’id’,用来唯一标识一幅图像。
id
用来唯一标识一个instance。
category_id
对应于后面’categories’部分的’id’,用来唯一标识一个类别。

annotation[‘categories’]

annotation['categories'] = [
	{
		'supercategory': 'vehicle',
		'id': 2,
		'name': 'bicycle'
	},
	{
		'supercategory': 'animal',
		'id': 22,
		'name': 'elephant'
	}
	...
]

全部类别如下:

supercategorysubcategoryid
personperson1
vehiclebicycle2
vehiclecar3
vehiclemotorcycle4
vehicleairplane5
vehiclebus6
vehicletrain7
vehicletruck8
vehicleboat9
outdoortraffic light10
outdoorfire hydrant11
outdoorstop sign13
outdoorparking meter14
outdoorbench15
animalbird16
animalcat17
animaldog18
animalhorse19
animalsheep20
animalcow21
animalelephant22
animalbear23
animalzebra24
animalgiraffe25
accessorybackpack27
accessoryumbrella28
accessoryhandbag31
accessorytie32
accessorysuitcase33
sportsfrisbee34
sportsskis35
sportssnowboard36
sportssports ball37
sportskite38
sportsbaseball bat39
sportsbaseball glove40
sportsskateboard41
sportssurfboard42
sportstennis racket43
kitchenbottle44
kitchenwine glass46
kitchencup47
kitchenfork48
kitchenknife49
kitchenspoon50
kitchenbowl51
foodbanana52
foodapple53
foodsandwich54
foodorange55
foodbroccoli56
foodcarrot57
foodhot dog58
foodpizza59
fooddonut60
foodcake61
furniturechair62
furniturecouch63
furniturepotted plant64
furniturebed65
furnituredining table67
furnituretoilet70
electronictv72
electroniclaptop73
electronicmouse74
electronicremote75
electronickeyboard76
electroniccell phone77
appliancemicrowave78
applianceoven79
appliancetoaster80
appliancesink81
appliancerefrigerator82
indoorbook84
indoorclock85
indoorvase86
indoorscissors87
indoorteddy bear88
indoorhair drier89
indoortoothbrush90
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值