coco数据集2

 一、COCO2017数据集格式

COCO_ROOT     #根目录
    ├── annotations        # 存放json格式的标注
    │     ├── instances_train2017.json   
    │     └── instances_val2017.json
    └── train2017         # 存放图片文件
    │     ├── 000000000001.jpg 
    │     ├── 000000000002.jpg 
    │     └── 000000000003.jpg 
    └── val2017        
          ├── 000000000004.jpg 
          └── 000000000005.jpg

COCO所有目标框标注都放在json文件中,json文件解析出来是一个字典,格式如下:

{
  "info": info, 
  "images": [image], 
  "annotations": [annotation], 
  "categories": [categories],
  "licenses": [license],
}

info记录关于数据集的一些基本信息

"info":{
	"description":"This is stable 1.0 version of the 2014 MS COCO dataset.",
	"url":"http:\/\/mscoco.org",
	"version":"1.0",
	"year":2017,
	"contributor":"Microsoft COCO group",
	"date_created":"2017-01-27 09:11:52.357475"
}

licenses是数据集遵循的一些许可,格式是list,其中内容为:

"licenses":{
	"url":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/2.0\/",
	"id":1,
	"name":"Attribution-NonCommercial-ShareAlike License"
}

制作自己的数据集的时候info和licenses是不需要的。只需要images,annotations和categories三个字段即可。

        其中images是一个字典的列表,储存图像的文件名,高宽和id,id是图象的编号,在annotations中也用到,是唯一的。有多少张图片,该列表就有多少个字典。

# json['images'][0]
{
  'file_name': '000000397133.jpg',
  'height': 427,
  'width': 640,
  'id': 397133
}

"images":{
    "coco_url": "", 
    "date_captured": "", 
    "file_name": "000001.jpg", 
    "flickr_url": "", 
    "id": 1, 
    "license": 0, 
    "width": 416, 
    "height": 416
}

 categories表示所有的类别,有多少类就定义多少,类别的id从1开始,0为背景。格式如下:

"categories":{
    "id": int,
    "name": str,
    "supercategory": str,
}

[
  {'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'}
  # ....
]

annotations是数据集中包含的实例掩膜,数量等于bounding box的数量。segmentation格式取决于这个实例是一个单个的对象(即iscrowd=0,将使用polygons格式,以多边形顶点表示)还是一组对象(即iscrowd=1,将使用RLE格式,mask编码)

annotations是检测框的标注,一个bounding box的格式如下:

{'segmentation': [[]],
 'area': 240.000,
 'iscrowd': 0,
 'image_id': 289343,
 'bbox': [0., 0., 60., 40.],
 'category_id': 1,
 'id': 1768}

"annotations":{
    "id": int,
    "image_id": int,
    "category_id": int,
    "segmentation": RLE or [polygon],
    "area": float,
    "bbox": [x,y,width,height],
    "iscrowd": 0 or 1
}

# 以多边形顶点形式表示的实例:
"annotations":{
	"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
}

//解析其中的类别ID、图像ID:
coco = COCO(annotation_file.json)
catIds = coco.getCatIds()
imgIds = coco.getImgIds()

  其中segmentation是分割的多边形,我对这个键的含义不是很懂,而且我用到的标注只有bbox,所知直接设置成了[[]],注意一定是两个列表嵌套,area是分割的面积,bbox是检测框的[x, y, w, h]坐标,category_id是类别id,与categories中对应,image_id图像的id,id是bbox的id,每个检测框是唯一的,有几个bbox,annotations里就有几个字

二、现有标注格式

        使用的数据来自阿里天池宫颈癌风险检测竞赛的数据集,经过预处理后获得图像及其对应的json文件标注信息,如下所示:

数据集下载

kfbreader.zip    59.8MB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/kfbreader.zip
labels.zip    210.29KB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/labels.zip
neg_0.zip    10.74GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/neg_0.zip
neg_1.zip    10.24GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/neg_1.zip
neg_2.zip    11.55GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/neg_2.zip
neg_3.zip    11.11GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/neg_3.zip
neg_4.zip    11.25GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/neg_4.zip
neg_5.zip    11.57GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/neg_5.zip
pos_0.zip    13.01GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/pos_0.zip
pos_1.zip    12.68GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/pos_1.zip
pos_2.zip    12.85GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/pos_2.zip
pos_3.zip    12.74GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/pos_3.zip
pos_4.zip    12.81GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/pos_4.zip
pos_5.zip    12.84GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/pos_5.zip
pos_6.zip    13.36GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/pos_6.zip
pos_7.zip    13.41GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/pos_7.zip
pos_8.zip    12.97GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/pos_8.zip
pos_9.zip    14.48GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/pos_9.zip
test_0.zip    12.03GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/test_0.zip
test_1.zip    12.5GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/test_1.zip
test_2.zip    12.64GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/test_2.zip
test_3.zip    11.4GB    http ://tianchi-competition.oss-cn-hangzhou.aliyuncs.com/231757/test_3.zip

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值