COCOデータセットの作成COCOデータセットの作成 C O C O数のデータ収集システムについて
【実際の戦闘】Windows10 + YOLOv3が独自のデータセットの検出を実現(1)-独自のデータセットを作成
まず、入力モデルのココ検出とセグメンテーションのデータ形式を決定します
COCOデータ形式に設定されたLabelme生産データ
COCOデータ形式に設定されたLabelimgデータ
cocoデータセットを使用して作成目标检测
および语义分割
cocoデータセットのラベル情報は.json形式で保存されます
はじめに
MSCOCOのフルネームはMicrosoftCommon Objects in Contextであり、Microsoftが2014年に資金提供して注釈を付けたMicrosoft COCOデータセットから派生しています。そのステータスはImageNetと同等であり、一般的なモデルのパフォーマンスを測定するための最良のデータセットの1つです。
COCOデータセットは、大きくて豊富なオブジェクト検出、セグメンテーション、およびキャプションデータセットです。
シーンの理解を目標として、それは主に複雑な日常のシーンから傍受され、画像内のターゲットは正確なセグメンテーションによってキャリブレーションされます。
この画像には、91種類のターゲット、328,000の画像、2,500,000のラベルが含まれています。
これまでにセマンティックセグメンテーションの最大のデータセットがあります。80のカテゴリと33万を超える画像があり、そのうち20万がラベル付けされています。データセット全体の個人数は150万を超えています。
ダウンロード
1.2014データセットhttp://msvocds.blob.core.windows.net/coco2014/train2014.zipをダウンロードします
2.2017データセットをダウンロードし
ます
http://images.cocodataset.org/zips/train2017.ziphttp://images.cocodataset.org/annotations/annotations_trainval2017.zip
http://images.cocodataset.org/zips/val2017.zip
http://images.cocodataset.org/annotations/stuff_annotations_trainval2017.zip
http://images.cocodataset.org/zips/test2017.zip
http://images.cocodataset.org/annotations/image_info_test2017.zip
実現事例
import json
import os
import cv2
import shutil
import xml.etree.ElementTree as ET
dataset = {
}
def readxml(dataset,xml,count):
tree = ET.parse(xml)
root = tree.getroot()
for child in root:
if child.tag == "size":
for s_ch in child:
if s_ch.tag == "width":
w = s_ch.text
else :
h = s_ch.text
elif child.tag == "object":
for s_ch in child:
if s_ch.tag == "bndbox":
for ss_ch in s_ch:
if ss_ch.tag == "xmin":
xmin = ss_ch.text
elif ss_ch.tag == "ymin":
ymin = ss_ch.text
elif ss_ch.tag == "xmax":
xmax = ss_ch.text
elif ss_ch.tag == "ymax":
ymax = ss_ch.text
else:
ca_name = s_ch.text
dataset.setdefault("images",[]).append({
'file_name': str(count) +'.jpg',
'id': int(count),
'width': int(w),
'height': int(h)
})
dataset.setdefault("annotations",[]).append({
'image_id': int(count),
'bbox': [int(xmin), int(ymin), int(xmax)-int(xmin), int(ymax)-int(ymin)],
'category_id': 6,
'area':int(w) * int(h),
'iscrowd':0,
'id':int(count),
'segmentation':[]
})
im_path="/home/qusongyun/images/"
trainimg = "/home/qusongyun/simpledet/data/coco/images/val2014/"
cmax = 0
dirpath = os.listdir(im_path)
for imgdir in dirpath:
f1 = os.listdir(trainimg)
for file in f1:
cmax = max(cmax,int(file.split(".")[0]))
count = 1
for file in os.listdir(im_path + imgdir):
if file.split(".")[1] == "jpg":
oldname = os.path.join(im_path + imgdir, file)
jpgname = os.path.join(trainimg, str(count+cmax) + ".jpg")
shutil.copyfile(oldname, jpgname)
readxml(dataset,os.path.join(im_path + imgdir , file.split(".")[0] + ".xml"),count+cmax)
count += 1
for i in range(1,81):
dataset.setdefault("categories",[]).append({
'id': i,
'name':1,
'supercategory': 'No'
})
folder = os.path.join('/home/qusongyun/simpledet/data/coco/annotations/')
if not os.path.exists(folder):
os.makedirs(folder)
json_name = os.path.join(folder+'instances_minival2014.json')
with open(json_name, 'w') as f:
json.dump(dataset, f)
参照
https://patrickwasp.com/create-your-own-coco-style-dataset/
独自のCOCOデータセットを作成し、マスクR-CNNをトレーニングします