Link to this sectionPASCAL VOC Dataset#
The PASCAL VOC (Visual Object Classes) dataset is a classic object detection benchmark with 20 everyday object classes. The Ultralytics VOC.yaml configuration combines the VOC2007 and VOC2012 trainval splits into a 16,551-image training set, validates on the 4,952 publicly annotated VOC2007 test images, and downloads everything automatically (2.8 GB) on first use.
Watch: How to Train Ultralytics YOLO on the Pascal VOC Dataset | Object Detection | Computer Vision 🚀
The PASCAL VOC challenges ran from 2005 to 2012 and shaped how object detection models are evaluated: the benchmark spans image classification, detection, and segmentation tasks, and popularized mean Average Precision (mAP) as the standard detection metric. The Ultralytics VOC.yaml configuration uses the detection annotations, converting the original XML bounding boxes to YOLO format during download.
Link to this sectionKey Features#
- 20 everyday object classes: person; six animals (bird, cat, cow, dog, horse, sheep); seven vehicles (aeroplane, bicycle, boat, bus, car, motorbike, train); and six indoor objects (bottle, chair, diningtable, pottedplant, sofa, tvmonitor).
- Two challenge generations combined: training merges VOC2007 trainval (5,011 images) with VOC2012 trainval (11,540 images).
- Standardized evaluation: decades of published VOC baselines make it a convenient reference point for comparing detection models.
- YOLO-ready: the download script fetches the archives and converts the annotations automatically — no manual preparation.
Link to this sectionDataset Structure#
The Ultralytics VOC.yaml configuration defines the following splits:
| Split | Images | Source |
|---|---|---|
| Train | 16,551 | VOC2007 trainval (5,011) + VOC2012 trainval (11,540) |
| Validation | 4,952 | VOC2007 test, used for evaluation during training |
| Test | 4,952 | The same VOC2007 test images — the config defines no separate held-out split |
VOC2007 test annotations were released publicly after that year's challenge, which is what allows this split to serve as a labeled validation set. VOC2012 test annotations remain withheld — results on them can only be scored through the official PASCAL evaluation server — so they are not part of this configuration.
The automatic converter skips objects flagged difficult in the original VOC XML annotations, so per-class instance counts differ slightly from official VOC statistics.
Explore VOC on Ultralytics Platform to browse the images with their annotation overlays, view the class distribution and bounding-box heatmaps in the Charts tab, and clone it to train your own model in the cloud.
Link to this sectionApplications#
PASCAL VOC was the primary benchmark for object detection research in the years before the larger COCO dataset: detectors such as Faster R-CNN and SSD reported their original results on it, and Ultralytics YOLO models train on it out of the box. Today it remains popular for:
- Benchmarking new detection architectures against a long history of published baselines
- Fast experiments and coursework — at 16,551 training images it trains far quicker than COCO
- Transfer learning studies on a compact, well-understood set of everyday classes
Link to this sectionDataset YAML#
The VOC.yaml file defines the dataset configuration — the dataset paths, the 20 class names, and the automatic download-and-convert script. It is maintained in the Ultralytics repository at 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, 5011 images
f"{ASSETS_URL}/VOCtest_06-Nov-2007.zip", # 438MB, 4952 images
f"{ASSETS_URL}/VOCtrainval_11-May-2012.zip", # 1.95GB, 17125 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 sectionUsage#
VOC downloads automatically the first time you train — three archives totaling 2.8 GB — and needs roughly 6 GB of free disk space during extraction and conversion.
To train a YOLO26n model on the VOC dataset for 100 epochs with an image size of 640, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model Training page.
from ultralytics import YOLO
# Load a model
model = YOLO("yolo26n.pt") # load a pretrained model (recommended for training)
# Train the model - dataset will auto-download on first run
results = model.train(data="VOC.yaml", epochs=100, imgsz=640)Link to this sectionSample Images and Annotations#
The image below shows a mosaiced training batch from the VOC dataset. Mosaicing combines multiple images into a single training sample, increasing the variety of objects, scales, and scene contexts the model sees in each batch — see the YOLO data augmentation guide for details.

Link to this sectionCitations and Acknowledgments#
If you use the VOC dataset in your research or development work, please cite the following paper:
@article{everingham2010pascal,
author={Everingham, Mark and Van Gool, Luc and Williams, Christopher K. I. and Winn, John and Zisserman, Andrew},
journal={International Journal of Computer Vision},
title={The Pascal Visual Object Classes (VOC) Challenge},
year={2010},
volume={88},
number={2},
pages={303-338},
doi={10.1007/s11263-009-0275-4}}We would like to acknowledge the PASCAL VOC Consortium for creating and maintaining this valuable resource for the computer vision community. For more information about the VOC dataset and its creators, visit the PASCAL VOC dataset website.
Link to this sectionFAQ#
Link to this sectionWhat is the PASCAL VOC dataset used for?#
PASCAL VOC is used to train and benchmark object detection models on 20 everyday object classes such as person, car, dog, and chair. Because it is compact, fully labeled, and backed by years of published baselines, it is a common choice for validating new architectures, running coursework experiments, and quick transfer learning studies.
Link to this sectionHow many images are in the PASCAL VOC dataset?#
The Ultralytics VOC configuration contains 21,503 images: 16,551 for training (VOC2007 trainval + VOC2012 trainval) and 4,952 for validation (the VOC2007 test set). All splits share the same 20 classes. See Dataset Structure for the full breakdown.
Link to this sectionHow do I download the PASCAL VOC dataset?#
VOC downloads automatically the first time you train with data="VOC.yaml" — no manual steps are required. The script fetches three archives (2.8 GB) from Ultralytics GitHub release assets and converts the XML annotations to YOLO format.
Link to this sectionHow do I train a YOLO26 model on the VOC dataset?#
Train a YOLO26n model on VOC for 100 epochs at an image size of 640:
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)For detailed configurations, see the Training page and model training tips.
Link to this sectionWhat is the difference between VOC2007 and VOC2012?#
Both challenges share the same 20 classes but contribute different images. VOC2007 provides 5,011 trainval images plus a 4,952-image test set whose annotations are public; VOC2012 provides 11,540 trainval images, while its test annotations are withheld and scored only by the official evaluation server. The Ultralytics VOC.yaml merges both trainval sets for training and validates on VOC2007 test.
Link to this sectionHow does PASCAL VOC compare to the COCO dataset?#
VOC is smaller and simpler: 20 classes and 21,503 images versus COCO's 80 classes and 330K images. VOC results are traditionally reported as mAP at 0.5 IoU, while COCO averages mAP over IoU thresholds from 0.5 to 0.95. VOC trains much faster and suits quick experiments; the COCO dataset is the standard for production-scale benchmarking.
Link to this sectionCan I train segmentation models with VOC.yaml?#
No — VOC.yaml is a detection-only configuration: its converter extracts bounding boxes from the VOC XML annotations, and the segmentation masks included in the original benchmark are not converted. To train an instance segmentation model, use a dataset with polygon labels such as COCO-Seg with a yolo26n-seg.pt model.