做阿里巴巴的网站的费用吗,ps 矢量素材网站,网站怎么做播放器,公司seo是什么级别目录 一、COCO数据集
1.COCO数据集下载
2.COCO数据集相关介绍
Captions.json文件
instances.json文件
Person_keypoints.json文件
3.提取instances中的边界框信息
二、VOC数据集
1.VOC数据集下载
VOC2007训练集验证集百度云资源#xff08;提取码6zg6#xff09;htt…目录 一、COCO数据集
1.COCO数据集下载
2.COCO数据集相关介绍
Captions.json文件
instances.json文件
Person_keypoints.json文件
3.提取instances中的边界框信息
二、VOC数据集
1.VOC数据集下载
VOC2007训练集验证集百度云资源提取码6zg6https://pan.baidu.com/s/1xKJwIcfAQ1nsi7CZUqqCiwVOC2007测试集百度云资源提取码zpmshttps://pan.baidu.com/s/1zDQqKRgaXjqfvGPMkSkjQg
2.VOC数据集相关介绍
Annotation文件夹
ImageSets文件夹
JPEGImages文件夹
SegmentationClass文件夹
SegmentationObject文件夹
3.提取xml文件中的边界框信息 一、COCO数据集
COCOCommon Objects in Context数据集是一个大型的、丰富的图像数据集广泛用与计算机视觉领域特别是目标检测、分割、姿态估计和图像标题生成等任务。COCO数据集由微软提供旨在推动场景理解的研究。 1.COCO数据集下载 COCO数据集官网下载需要科学上网https://cocodataset.org/#download
COCO2014数据集_数据集-飞桨AI Studio星河社区COCO2014https://aistudio.baidu.com/datasetdetail/28191COCO2017-完整数据集_数据集-飞桨AI Studio星河社区object instances目标实例, object keypoints目标上的关键点, 和image captions看图说话使用JSON文件存储COCO数据集共有大类12个小类80个https://aistudio.baidu.com/datasetdetail/97273
2.COCO数据集相关介绍
COCO数据集总共有80个类,在COCO2014中训练集、验证集和测试集总共有164,063张图像。
Person: personAnimalbird, cat, dog, horse, sheep, cow, elephant, bear, zebra, giraffeVehiclebicycle, car, motorbike, aeroplane, bus, train, truck, boatFacilitiestraffic light, fire hydrant, stop sign, parking meter, benchNecessitiesbackpack, umbrella, handbag, tie, suitcaseSportsfrisbee, skis, snowboard, sports ball, kite, baseball bat, baseball glove, skateboard, surfboard, tennis racketKitchenbottle, wine glass, cup, fork, knife,spoon, bowlFoodbanana, apple, sandwich, orange, broccoli, carrot, hot dog, pizza, donut, cake,Furniturechair, sofa, pottedplant, bed, diningtable, toilet, tvmonitorElectroniclaptop, mouse, remote, keyboard, cell phoneAppliancemicrowave, oven, toaster, sink, refrigeratorIndoorbook, clock, vase, scissors, teddy bear, hair drier, toothbrush
COCO数据集下载并解压后主要有2个文件夹。
images包含了数据集的图片训练集、验证集和测试集的图片annotations包含了与图片对应的标注文件主要是JSON格式的标注文件
以COCO2014为例images中包含三个文件夹train2014、val2014和test2014这三个文件夹里分别代表训练集、验证集和测试集的图片所有的图片基本上都是JPG格式。 annotation文件夹中有captions_train2014.json、captions_val2014.json、captions_test2014.json、instances_train2014.json、instances_val2014.json、instances_test2014.json、person_keypoints_train2014.json、person_keypoints_val2014.json、person_keypoints_test2014.json。这些都是标注文件文件名后的train、val、test代表是训练集、验证集和测试集的标注文件。 Captions.json文件
Captions.json文件里的内容是对数据集的相关介绍信息如数据集的版本号、年份、作者、数据集的许可证信息、图片的相关信息每张图片的名称、尺寸、URL等。 instances.json文件
instances.json文件是一个关键的标注文件它包含了图像中实例如物体、人等的详细信息。
主要内容是annotations和categories。annotations包含标注信息每个标注项代表一个目标实例的详细信息bbox边界框segmentation分割掩码、area实例所占据面积、iscrowd标注位、category_id类别ID)和id标注ID等。
bbox一个包含四个值的数组[x,y,w,h]表示标注对象的边界框x和y是边界框的左上角坐标w和h是边界框的宽度和高度。segmentation实例的分割掩码可选。这可以是一个多边形列表表示实例的像素级轮廓也可以是一个二进制掩码在某些情况下其中每个像素都标识为前景实例或背景。iscrowd指示实例是否是“杂乱”的例如一群紧密排列的物体被视为单个实例。在COCO数据集中这通常用于人群等密集场景。 Person_keypoints.json文件
Person_keypoints.json文件是人体关键点检测任务的标注信息其中主要内容是关键点标注信息主要是annotations中的kerpoints关键点和bbox边界框。
keypoints一个长度为3*k的数组集中k是关键点总数在COCO数据集中对于人体关键点检测任务k通常是17。每个关键点由三个值组成[xyv]x和y是关键点的坐标值v是可见性标志v0表示关键点未标注v1表示关键点标注了但不可见v2表示关键点标注了且可见。bbox一个包含四个值的数组[x,y,w,h]表示标注对象的边界框x和y是边界框的左上角坐标w和h是边界框的宽度和高度。 3.提取instances中的边界框信息
提取的数据量较大需要在pycharm中设置txt文本的最大限制。 加入以下代码
idea.max.intellisense.filesize20000
idea.max.content.load.filesize20000
然后重启pytcharm 边界框信息提取代码如下
import jsondef extract_annotation(coco_data, list_file): # 提取xml中的信息d {}for annotation in coco_data[annotations]:# 检查annotation中是否包含bbox字段理论上应该总是包含if bbox in annotation:# bbox格式为[x, y, width, height]其中(x, y)是左上角坐标bbox annotation[bbox]# 将提取出的bbox转成[x1,y1,x2,y2],x1和y1是左上角坐标x2和y2是右下角坐标bbox[2] bbox[0] bbox[2]bbox[3] bbox[1] bbox[3]# 将图像ID和类别ID与边界框一起存储以便于后续处理category_id annotation[category_id]bbox.append(category_id)image_id annotation[image_id]if image_id not in d.keys():d[image_id] []d[image_id].append(bbox) # 汇聚属于同一图片的标注信息lines list(d.keys())for line in lines:bboxes d[line]filename {:012}.jpg.format(line)for b in bboxes:filename filename ,.join([str(int(a)) for a in b])list_file.write(filename \n) # 写入信息if __name__ __main__:# coco数据集版本以COCO2014为例coco_year 2014# 加载JSON文件with open(annotations/instances_train{}.json.format(coco_year), r) as f:coco_data json.load(f)with open(train.txt, w) as g:extract_annotation(coco_data, g)with open(annotations/instances_val{}.json.format(coco_year), r) as f:coco_data json.load(f)with open(val.txt, w) as g:extract_annotation(coco_data, g)# 加载JSON文件with open(annotations/instances_test{}.json.format(coco_year), r) as f:coco_data json.load(f)with open(test.txt, w) as g:extract_annotation(coco_data, g)以上代码以COCO2014数据集为例进行提取提取的信息整理后的格式如下所示。 二、VOC数据集
VOC数据集全称Visual Object Classes(视觉对象类别)数据集是一个广泛应用于计算机视觉领域的数据集特别是在目标检测、图像分割和图像分类等任务中。VOC数据集最初由英国牛津大学的计算机视觉小组创建并在PASCAL VOC挑战赛中使用该数据包含大量的带有标注信息的图像用于训练和评估图像识别算法。VOC数据集涵盖了多个年度的发布每个年度都包含了训练集、验证集和测试集。
1.VOC数据集下载
VOC2007训练集验证集http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tarVOC2007测试集http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tarVOC2012训练集验证集http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar
VOC2007训练集验证集百度云资源提取码6zg6https://pan.baidu.com/s/1xKJwIcfAQ1nsi7CZUqqCiwVOC2007测试集百度云资源提取码zpmshttps://pan.baidu.com/s/1zDQqKRgaXjqfvGPMkSkjQg
2.VOC数据集相关介绍
VOC数据集总共有20个类,在VOC2007中训练集、验证集和测试集总共有9963张图像包含24640个目标。
Person: personAnimal: bird, cat, cow, dog, horse, sheepVehicle: aeroplane, bicycle, boat, bus, car, motorbike, trainIndoor: bottle, chair, dining table, potted plant, sofa, tv/monitor VOC2007下载并解压后有五个文件夹。
Annotations进行目标检测任务是的标签文件xml格式ImageSets存放数据集分割文件文本格式JPEGImages存放所有图片jpg格式SegmentationClass存放语义分割图片png格式SementationObject存放实例分割图片png格式 Annotation文件夹
Annotation中每一个xml文件对应一张图片的标签信息如下所示
annotationfolderVOC2007/folderfilename000001.jpg/filename #对应图片名称sourcedatabaseThe VOC2007 Database/database #数据集annotationPASCAL VOC2007/annotation imageflickr/imageflickrid341012865/flickrid/sourceownerflickridFried Camels/flickridnameJinky the Fruit Bat/name/ownersize #图片尺寸width353/widthheight500/heightdepth3/depth/sizesegmented0/segmentedobjectnamedog/name #第一个目标信息类别坐标位置等poseLeft/posetruncated1/truncateddifficult0/difficultbndboxxmin48/xminymin240/yminxmax195/xmaxymax371/ymax/bndbox/objectobjectnameperson/name #第二个目标信息类别坐标位置等poseLeft/posetruncated1/truncateddifficult0/difficultbndboxxmin8/xminymin12/yminxmax352/xmaxymax498/ymax/bndbox/object
/annotation ImageSets文件夹
ImageSets文件夹中存放三种数据集分割文件夹LayoutMainSegmentation其中Main文件夹存放的是用于分类和检测的数据集分割文件Layout文件夹用于 person layout任务Segmentation用于分割任务。如下图所示里面的各个文本文件中是各样本名代表某张图片和对应的标签文件作为train或val或test。 除了数据集分割文件在Main文件夹中还有各个类别在train或val或test中的ground truth这个ground truth是为了方便分类任务而提供的。如下图所示第一列代表那一个样本即样本名第二列只有1和-1代表该图片是否属于该类如areoplane_train.txt文本中的000012样本就不属于areoplane类,所以为-1即0000012.jpg中并没有飞机目标。而000033样本就属于areoplane类代表0000033.jpg中有飞机目标。 JPEGImages文件夹
JPEGImages存放所有图片训练集、验证集、测试集所有图片均为JPG格式。如下图所示 SegmentationClass文件夹
SegmentationClass文件夹是存放语义分割任务中用到的标签图片。在语义分割任务中不同类别像素点会被标注为不同的颜色从而实现对每个像素点的分类。 SegmentationObject文件夹
SegmentationObject文件夹是存放实例分割任务中用到的标签图片。在实例分割任务中不仅要区分不同类别的对象还需要区分同一类别的不同对象。 3.提取xml文件中的边界框信息 XML中信息读取代码如下所示
import xml.etree.ElementTree as ET
import numpy as np# ----------------------------------------------VOC数据集中所有类-----------------------------------------------------------#
classes [aeroplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, diningtable,dog, horse, motorbike, person, pottedplant, sheep, sofa, train, tvmonitor]nums np.zeros(len(classes))def extract_annotation(year, image_id, list_file): # 提取xml中的信息in_file open(VOC%s/Annotations/%s.xml % (year, image_id), encodingutf-8)tree ET.parse(in_file)root tree.getroot()filename root.find(filename).text # 图片名for obj in root.iter(object):cls obj.find(name).text # 类别difficult 0if obj.find(difficult) ! None:difficult obj.find(difficult).textif cls not in classes or int(difficult) 1: # 不属于classes中的类或者检测难度较大的则舍弃continuecls_id classes.index(cls) # 类别转成数值idxmlbox obj.find(bndbox) # 坐标信息b (int(float(xmlbox.find(xmin).text)), int(float(xmlbox.find(ymin).text)),int(float(xmlbox.find(xmax).text)), int(float(xmlbox.find(ymax).text)))filename filename ,.join([str(a) for a in b]) , str(cls_id)list_file.write(filename \n) # 写入信息if __name__ __main__:voc_year 2007 # 下载的VOC数据集版本 以VOC2007为例with open(VOC%s/ImageSets/Main/train.txt % (voc_year)) as f: # 获得训练集的所有样本名train_names f.readlines()train_names [line.rstrip(\n) for line in train_names]with open(VOC%s/train.txt % (voc_year), w) as g: # 提取信息for name in train_names:extract_annotation(voc_year, name, g)with open(VOC%s/ImageSets/Main/val.txt % (voc_year)) as f: # 获得验证集的所有样本名val_names f.readlines()val_names [line.rstrip(\n) for line in val_names]with open(VOC%s/val.txt % (voc_year), w) as g:for name in val_names:extract_annotation(voc_year, name, g)with open(VOC%s/ImageSets/Main/test.txt % (voc_year)) as f: # 获得测试集的所有样本名test_names f.readlines()test_names [line.rstrip(\n) for line in test_names]with open(VOC%s/test.txt % (voc_year), w) as g:for name in test_names:extract_annotation(voc_year, name, g)以上代码以VOC2007的数据集为例进行提取提取的信息整理后的格式如下所示。