关于VOC与COCO数据集文件里的内容

本文的内容基于PASCAL VOC2012和COCO2014,若有不当之处,还请各位教正。

VOC

下载VOC后打开,得到以下五个文件夹:

  • JPEGImages
  • Annotations
  • ImageSets
  • SegmentationClass
  • SegmentationObject

1、JPEGImages

PASCAL VOC提供的所有的图片,其中包括训练图片,测试图片,总共1712张。

2、Annotations

存放xml格式的标签文件,每个xml对应JPEGImage中的一张图片。
包含以下信息(#标注是我自己加的):

<annotation>
	<folder>JPEGImages</folder>
	<filename>01.jpg</filename>		  # 文件名
	<path>D:\Datasets\My_datas\VOC\JPEGImages\01.jpg</path>
	<source>
		<database>Unknown</database>
	</source>
	<size>							   # 图像尺寸(长宽以及通道数)
		<width>1920</width>
		<height>1080</height>
		<depth>3</depth>
	</size>
	<segmented>0</segmented>			# 是否用于分割(在图像物体识别中01无所谓)
	<object>							# 检测到的物体
		<name>car</name>					# 物体类别
		<pose>Unspecified</pose>			# 拍摄角度(目标的姿势)
		<truncated>0</truncated>			# 目标是否被截断(0表示不是)
		<difficult>0</difficult>			# 目标是否难以识别(0表示容易识别)
		<bndbox>							# bounding box左下、右下角xy坐标
			<xmin>735</xmin>
			<ymin>230</ymin>
			<xmax>1917</xmax>
			<ymax>806</ymax>
		</bndbox>
	</object>
</annotation>

3、ImageSets

  • Action:人的动作
  • Layout:人体的具体部位
  • Main: 图像物体识别的数据,总共20类, 需要保证train val没有交集
    • train.txt:训练集
    • val.txt:验证集validation
    • trainval.txt:训练和验证集
  • Segmentation:用于分割的数据

Main 和 Segmentation的作用相当于名单,当模型要用的时候,根据名单找到对应的 img。

4、SegmentationObject & SegmentationClass

  • SegmentationClass:用于语义分割
  • SegmentationObject:用于实例分割

两者img数都是2913.

另外,语义分割与实例分割的区别在于:

  • 语义分割:标出某一类物体,只能判断类别,无法区分个体;
  • 实例分割:标出某一个个体,可以区分出单个个体。

因此打开SegmentationObject 和 SegmentationClass 可发现两者异同
图1
图2

COCO

我只下载了object annotations 和所有 Images。
Images文件里分别存放了train图像82783张和val图像40504张。

object annotations 里分别是 train 和 val 的 json文件。
整理了一下,部分内容如下:

<class ‘dict’>

  • 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":[ 
          {
          "license": 5,
          "file_name": "COCO_train2014_000000057870.jpg",  # 图片名
          "coco_url": "http://mscoco.org/images/57870",
          "height": 480,  # 高
          "width": 640,  # 宽
          "date_captured": "2013-11-14 16:28:13",
          "flickr_url": "http://farm4.staticflickr.com/3153/2970773875_164f0c0b83_z.jpg",
          "id": 57870  # 图片的id编号(每张图的id编号是唯一的)
          },
          ......]
  • licenses:许可证
"licenses":[
           {
           "url": "http://creativecommons.org/licenses/by-nc-sa/2.0/",
           "id": 1,
           "name": "Attribution-NonCommercial-ShareAlike License"
           },
           ......]
  • annotations:每个annotation只是表示一个目标的label,多个annotation
    可指向同一img
"annotations":[ 
              {
              "segmentation": {  # 对象边界点(多边形),是语义分割的label
                              "counts":[312.29, 562.89,  # 第一个点xy坐标
                                        402.25, 511.49,  # 第二个点xy坐标
                                        400.96, 425.38,
                                        ...     ...   ,
                                        300.72, 571.89],
                              "size": [427, 640]
                              }
              "area": 54652.9556,  # 语义分割或bbox的区域大小
              "iscrowd": 0,  # 是否是人群
              "image_id": 480023,  # 对应的img的id
              "bbox": [116.95, 305.86, 285.3, 266.03],  # 目标框
              "category_id": 58,  # 类别的标识
              "id": 86  # 每个目标的id,是annotation的唯一标识
              },
              ......]
  • categories
"categories":[  # 类别描述
             {
             "supercategory": "vehicle",  # 主类别
             "id": 2,  # 类别对应id(0为背景)
             "name": "bicycle"  # 子类别
              },
              ......]

在使用的时候,我们只需取出 images,annotations 和 categories 即可。

参考文献:
[1] https://blog.csdn.net/See_Star/article/details/103546650.
[2] https://zhuanlan.zhihu.com/p/50996404.
[3] https://blog.csdn.net/qq_30638831/article/details/83148308.
[4] https://blog.csdn.net/fireflychh/article/details/83040205.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值