Link to this sectionVOCデータセット#
PASCAL VOC (Visual Object Classes) データセットは、物体検出、セグメンテーション、および分類において広く知られているデータセットです。幅広い種類の物体カテゴリに関する研究を促進するために設計されており、コンピュータビジョンモデルのベンチマークによく使用されます。これは、物体検出、セグメンテーション、および分類タスクに取り組む研究者や開発者にとって不可欠なデータセットです。
Watch: How to Train Ultralytics YOLO26 on the Pascal VOC Dataset | Object Detection 🚀
Link to this section主な特徴#
- VOCデータセットには、VOC2007とVOC2012という2つの主要なチャレンジが含まれています。
- このデータセットは、車、自転車、動物といった一般的な物体に加え、ボート、ソファ、ダイニングテーブルなどのより具体的なカテゴリを含む20の物体カテゴリで構成されています。
- アノテーションには、物体検出および分類タスク用の物体BBoxとクラスラベル、さらにセグメンテーションタスク用のセグメンテーションマスクが含まれます。
- VOCは、物体検出や分類のためのmean Average Precision (mAP) といった標準化された評価指標を提供しており、モデルの性能比較に適しています。
Link to this sectionデータセットの構造#
VOCデータセットは、以下の3つのサブセットに分割されています。
- Train: このサブセットには、物体検出、セグメンテーション、および分類モデルのトレーニングに使用される画像が含まれています。
- Validation: このサブセットには、モデルのトレーニング中に検証目的で使用される画像が含まれています。
- Test: このサブセットは、トレーニング済みモデルのテストおよびベンチマークに使用される画像で構成されています。このサブセットの正解ラベル(Ground truth)は公開されておらず、以前はPASCAL VOC評価サーバーに結果を送信して性能を評価していました。
Link to this sectionアプリケーション#
The VOC dataset is widely used for training and evaluating deep learning models in object detection (such as Ultralytics YOLO, Faster R-CNN, and SSD), instance segmentation (such as Mask R-CNN), and image classification. The dataset's diverse set of object categories, large number of annotated images, and standardized evaluation metrics make it an essential resource for computer vision researchers and practitioners.
Link to this sectionデータセット YAML#
データセットの構成を定義するには、YAML (Yet Another Markup Language) ファイルが使用されます。これには、データセットのパス、クラス、およびその他の関連情報が含まれます。VOCデータセットの場合、VOC.yamlファイルが https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/VOC.yaml で管理されています。
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
# PASCAL VOC dataset http://host.robots.ox.ac.uk/pascal/VOC by University of Oxford
# Documentation: https://docs.ultralytics.com/datasets/detect/voc
# Example usage: yolo train data=VOC.yaml
# parent
# ├── ultralytics
# └── datasets
# └── VOC ← downloads here (2.8 GB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: VOC
train: # train images (relative to 'path') 16551 images
- images/train2012
- images/train2007
- images/val2012
- images/val2007
val: # val images (relative to 'path') 4952 images
- images/test2007
test: # test images (optional)
- images/test2007
# Classes
names:
0: aeroplane
1: bicycle
2: bird
3: boat
4: bottle
5: bus
6: car
7: cat
8: chair
9: cow
10: diningtable
11: dog
12: horse
13: motorbike
14: person
15: pottedplant
16: sheep
17: sofa
18: train
19: tvmonitor
# Download script/URL (optional) ---------------------------------------------------------------------------------------
download: |
import xml.etree.ElementTree as ET
from pathlib import Path
from ultralytics.utils.downloads import download
from ultralytics.utils import ASSETS_URL, TQDM
def convert_label(path, lb_path, year, image_id):
"""Converts XML annotations from VOC format to YOLO format by extracting bounding boxes and class IDs."""
def convert_box(size, box):
dw, dh = 1.0 / size[0], 1.0 / size[1]
x, y, w, h = (box[0] + box[1]) / 2.0 - 1, (box[2] + box[3]) / 2.0 - 1, box[1] - box[0], box[3] - box[2]
return x * dw, y * dh, w * dw, h * dh
with open(path / f"VOC{year}/Annotations/{image_id}.xml") as in_file, open(lb_path, "w", encoding="utf-8") as out_file:
tree = ET.parse(in_file)
root = tree.getroot()
size = root.find("size")
w = int(size.find("width").text)
h = int(size.find("height").text)
names = list(yaml["names"].values()) # names list
for obj in root.iter("object"):
cls = obj.find("name").text
if cls in names and int(obj.find("difficult").text) != 1:
xmlbox = obj.find("bndbox")
bb = convert_box((w, h), [float(xmlbox.find(x).text) for x in ("xmin", "xmax", "ymin", "ymax")])
cls_id = names.index(cls) # class id
out_file.write(" ".join(str(a) for a in (cls_id, *bb)) + "\n")
# Download
dir = Path(yaml["path"]) # dataset root dir
urls = [
f"{ASSETS_URL}/VOCtrainval_06-Nov-2007.zip", # 446MB, 5012 images
f"{ASSETS_URL}/VOCtest_06-Nov-2007.zip", # 438MB, 4953 images
f"{ASSETS_URL}/VOCtrainval_11-May-2012.zip", # 1.95GB, 17126 images
]
download(urls, dir=dir / "images", threads=3, exist_ok=True) # download and unzip over existing (required)
# Convert
path = dir / "images/VOCdevkit"
for year, image_set in ("2012", "train"), ("2012", "val"), ("2007", "train"), ("2007", "val"), ("2007", "test"):
imgs_path = dir / "images" / f"{image_set}{year}"
lbs_path = dir / "labels" / f"{image_set}{year}"
imgs_path.mkdir(exist_ok=True, parents=True)
lbs_path.mkdir(exist_ok=True, parents=True)
with open(path / f"VOC{year}/ImageSets/Main/{image_set}.txt") as f:
image_ids = f.read().strip().split()
for id in TQDM(image_ids, desc=f"{image_set}{year}"):
f = path / f"VOC{year}/JPEGImages/{id}.jpg" # old img path
lb_path = (lbs_path / f.name).with_suffix(".txt") # new label path
f.rename(imgs_path / f.name) # move image
convert_label(path, lb_path, year, id) # convert labels to YOLO formatLink to this section使用方法#
VOCデータセット上でYOLO26nモデルを画像サイズ640で100 エポックトレーニングするには、以下のコードスニペットを使用できます。利用可能な引数の包括的なリストについては、モデルのトレーニングページを参照してください。
from ultralytics import YOLO
# Load a model
model = YOLO("yolo26n.pt") # load a pretrained model (recommended for training)
# Train the model
results = model.train(data="VOC.yaml", epochs=100, imgsz=640)Link to this sectionサンプル画像とアノテーション#
VOCデータセットには、さまざまな物体カテゴリと複雑なシーンを含む多様な画像セットが含まれています。データセットに含まれる画像と、それに対応するアノテーションの例を以下に示します。

- モザイク画像: この画像は、モザイク処理されたデータセット画像で構成されるトレーニングバッチを示しています。モザイク処理は、トレーニング中に複数の画像を1つの画像に結合し、各トレーニングバッチ内のオブジェクトやシーンの多様性を高める技術です。これにより、さまざまなオブジェクトのサイズ、アスペクト比、およびコンテキストに対してモデルが汎化する能力を向上させます。
この例は、VOCデータセットに含まれる画像の多様性と複雑さ、そしてトレーニングプロセス中にモザイク処理を使用する利点を示しています。
Link to this section引用と謝辞#
VOCデータセットを研究や開発で使用する場合は、以下の論文を引用してください。
@misc{everingham2010pascal,
title={The PASCAL Visual Object Classes (VOC) Challenge},
author={Mark Everingham and Luc Van Gool and Christopher K. I. Williams and John Winn and Andrew Zisserman},
year={2010},
eprint={0909.5206},
archivePrefix={arXiv},
primaryClass={cs.CV}
}コンピュータビジョンコミュニティのためにこの貴重なリソースを作成・維持してくださったPASCAL VOCコンソーシアムに感謝いたします。VOCデータセットとその作成者の詳細については、PASCAL VOCデータセットのウェブサイトをご覧ください。
Link to this sectionよくある質問 (FAQ)#
Link to this sectionPASCAL VOCデータセットとは何ですか?また、なぜコンピュータビジョンのタスクにおいて重要なのでしょうか?#
PASCAL VOC (Visual Object Classes) データセットは、コンピュータビジョンにおける物体検出、セグメンテーション、分類のための著名なベンチマークです。20の異なる物体カテゴリにわたるBBox、クラスラベル、セグメンテーションマスクなどの包括的なアノテーションが含まれています。研究者は、mean Average Precision (mAP) といった標準化された評価指標があるため、Faster R-CNN、YOLO、Mask R-CNNなどのモデルの性能評価にこのデータセットを広く利用しています。
Link to this sectionVOCデータセットを使用してYOLO26モデルをトレーニングするにはどうすればよいですか?#
VOCデータセットでYOLO26モデルをトレーニングするには、YAMLファイルでデータセット構成を指定する必要があります。以下は、画像サイズ640で100エポックのYOLO26nモデルのトレーニングを開始するための例です。
from ultralytics import YOLO
# Load a model
model = YOLO("yolo26n.pt") # load a pretrained model (recommended for training)
# Train the model
results = model.train(data="VOC.yaml", epochs=100, imgsz=640)Link to this sectionVOCデータセットにはどのような主要なチャレンジが含まれていますか?#
VOCデータセットには、VOC2007とVOC2012という2つの主要なチャレンジが含まれています。これらのチャレンジでは、20の多様な物体カテゴリにわたって物体検出、セグメンテーション、分類のテストを行います。各画像には、BBox、クラスラベル、セグメンテーションマスクが詳細にアノテーションされています。これらのチャレンジは、mAPなどの標準化された指標を提供し、異なるコンピュータビジョンモデルの比較やベンチマークを容易にします。
Link to this sectionPASCAL VOCデータセットは、どのようにモデルのベンチマークと評価を強化しますか?#
PASCAL VOCデータセットは、詳細なアノテーションとmean Average Precision (mAP) といった標準化された指標を通じて、モデルのベンチマークと評価を強化します。これらの指標は、物体検出モデルや分類モデルの性能を評価するために極めて重要です。このデータセットの多様で複雑な画像は、さまざまな現実世界のシナリオにおけるモデルの包括的な評価を確実にします。
Link to this sectionYOLOモデルでセマンティックセグメンテーションのためにVOCデータセットを使用するにはどうすればよいですか?#
YOLOモデルでセマンティックセグメンテーションタスクにVOCデータセットを使用するには、YAMLファイルでデータセットを適切に構成する必要があります。YAMLファイルは、セグメンテーションモデルのトレーニングに必要なパスとクラスを定義します。詳細な設定については、VOC.yamlのVOCデータセットYAML構成ファイルを確認してください。セグメンテーションタスクでは、検出モデルではなく、yolo26n-seg.ptのようなセグメンテーション専用モデルを使用します。