AI Logic

Datasets and Benchmarks

PASCAL VOC

Updated:

How PASCAL VOC was built and its annotation types. Left: the flow from Flickr photos, through duplicate removal, annotation at a single event, and checking by the organizers, to VOC2007 and VOC2012, each split into trainval and test. Right: the class and box, flags, masks, and person layout and action annotations attached to a single photo, and the evaluation rules for AP and segmentation

Overview

PASCAL VOC (Visual Object Classes) is a dataset of Flickr photos annotated by hand with bounding boxes for objects of 20 classes, plus pixel-level regions for a subset of the images, together with the challenge built on it. The challenge ran every year from 2005 to 2012 and became the standard benchmark for object detection. The dataset and its evaluation procedure are described in the 2010 IJCV paper by Everingham et al.

The challenge tasks are:

  • Classification: predict whether the image contains at least one object of a given class.
  • Detection: predict a bounding box for every object of a given class.
  • Segmentation: predict, for each pixel, one of the 20 classes or background (from 2007).
  • Person layout: predict bounding boxes for a person's head, hands, and feet (from 2007).
  • Action classification: predict what the person in the photo is doing (running, phoning, etc.; 10 actions in 2012).

The 20 classes fall into four groups: vehicles, animals, household objects, and people. The set grew from 4 classes in 2005 (car, motorbike, bicycle, person) to 10 classes in 2006 and 20 classes in 2007.

In deep learning papers, "VOC" usually refers to two releases: VOC2007 and VOC2012. The VOC2007 test annotations are public, so results can be computed locally; the VOC2012 test annotations are withheld, and results are scored by an evaluation server.

"VOC mAP" counts a detection as correct when its IoU (the overlap ratio between the predicted and ground-truth boxes) exceeds 0.5, and averages the AP over the 20 classes. This criterion is looser than COCO AP (averaged over IoU 0.50–0.95), so the same model scores higher on it.

Contents: construction, classes, splits, and format

VOC2007 was built in the following steps.

  1. Collect photos. For each class, Flickr was queried with the class name, its synonyms, and words for scenes where the object commonly appears (e.g., "street" and "road" for "car"), and images were sampled at random from the results. About 500,000 images were retrieved in total. Because researchers did not hand-pick photos, the set avoids a bias toward large, centered objects.
  2. Remove duplicates. Exact duplicates and near-duplicates that differ only in compression or similar details are removed.
  3. Annotate. Annotators gathered at the University of Leeds and worked in a single "annotation event" following common guidelines. They boxed every object of the 20 classes in each image and added flags such as viewpoint and truncation. Of the 44,269 images examined, those with no objects of the 20 classes, or that could not be annotated with confidence, were discarded.
  4. Check. One of the organizers checked the annotations of every image, fixed missed objects, and marked objects that are especially hard to recognize as difficult.

Annotating in one place at one time kept the class definitions and box conventions consistent. At the time of the paper, only one annotation error had been reported for VOC2007 (a missing viewpoint flag).

Per-object annotations are as follows.

FieldContent
ClassOne of the 20 classes
BoxAn axis-aligned rectangle around the visible extent of the object. [left, top, right, bottom], with the top-left pixel of the image at (1, 1)
ViewpointFrontal, rear, left, right, or unspecified
truncatedThe object extends outside the image or is cut off by an object in front, so the box does not cover the whole object
occludedA large part of the object is hidden by other objects (from 2008)
difficultThe object is especially hard to recognize because it is small, dark, or needs surrounding context. Excluded from evaluation

Segmentation annotations exist only for a subset of the images. They come as two kinds of PNG: "class" masks, which color each pixel by class, and "object" masks, which color each pixel by object index. A 5-pixel band along object boundaries is labeled void (value 255), left undecided between object and background, and is not used in evaluation, because pixel-exact labeling would take too long. difficult objects are also filled with void.

The VOC2007 splits are shown below. The train/validation set (trainval) and the test set are roughly half each, and trainval is further distributed as separate training (train) and validation (val) sets.

SplitImagesObjects
train2,5016,301
val2,5106,307
test4,95212,032
Total9,96324,640

The person class is by far the largest (9,218 objects); the other classes range from 421 (dining table) to 2,421 (car). Many Flickr photos are snapshots of family events and the like, and boxing every object in them yields many people.

VOC2012 classification/detection data consists of images from 2008–2011 and is identical to the 2011 release. Its trainval set has 11,540 images and 27,450 objects (excluding difficult ones), and the test set is about the same size, with annotations withheld. The segmentation set has 2,913 trainval images and 6,929 objects. The action classification and person layout tasks use image sets separate from classification/detection.

Evaluation protocol

Classification and detection are evaluated by per-class AP (Average Precision). The computation follows the mAP article; this section summarizes the VOC-specific rules.

  1. Sort predictions by confidence in descending order.
  2. In detection, a prediction is correct when the overlap between the predicted box BpB_p and the ground-truth box BgtB_{gt} exceeds 0.5.
ao=area(Bp∩Bgt)area(Bp∪Bgt)>0.5a_o = \frac{\mathrm{area}(B_p \cap B_{gt})}{\mathrm{area}(B_p \cup B_{gt})} > 0.5
  1. Multiple detections of the same object count as one true positive and the rest as false positives (5 detections give 1 true positive and 4 false positives). Merging overlapping predictions is the participant's model's job.
  2. difficult objects are ignored, whether detected or missed.
  3. Precision and recall at each rank form a curve, and the precision at each recall is replaced by the maximum precision achieved at any recall at or above it (interpolation).
pinterp(r)=max⁡r~≥rp(r~)p_{\mathrm{interp}}(r) = \max_{\tilde{r} \ge r} p(\tilde{r})
  1. AP is computed from the interpolated curve. VOC2007 averages it at 11 recall points 0, 0.1, …, 1; from VOC2010 on, it is the area under the curve (summed over intervals split at every recall value).
AP2007=111∑r∈{0,0.1,…,1}pinterp(r)\mathrm{AP}_{2007} = \frac{1}{11}\sum_{r \in \{0, 0.1, \dots, 1\}} p_{\mathrm{interp}}(r)

The mean of the AP over the 20 classes is called mAP. The 2010 change made AP more precise and able to distinguish methods with low AP.

The IoU threshold of 0.5 is deliberately low because the ground-truth boxes themselves are ambiguous. For objects such as a person with spread arms and legs, where to draw the box varies from annotator to annotator. The paper shows that, for the "car" class of VOC2007, raising the threshold above 0.5 makes AP drop sharply, while lowering it to 0.1 raises AP by about 7.5%.

Segmentation is evaluated by per-class IoU.

accuracy=TPTP+FP+FN\text{accuracy} = \frac{\text{TP}}{\text{TP} + \text{FP} + \text{FN}}

TP, FP, and FN are the numbers of true-positive, false-positive, and false-negative pixels for the class. The final score is the mean over 21 classes including background (mIoU), with void pixels ignored. VOC2007 measured the fraction of ground-truth pixels predicted correctly for each class, but labeling every pixel as "car" would then give a perfect score for the car class, so VOC2008 switched to this formula, which also penalizes false-positive pixels.

Use of the test set is also regulated. All tuning is done on trainval, and the test set is used only to report results. Each method may submit only one result; variants that differ only in parameters do not count as separate methods.

In VOC2005 the test annotations were released, and some participants tried many parameter settings on the test set and reported only the best result. The VOC2007 test annotations are public, so the same thing can happen. Choose hyperparameters on a validation split carved out of trainval, and evaluate on VOC2007 test only once at the end.

Usage and historical significance

PASCAL VOC was the standard object detection benchmark even before deep learning. The paper reports that, in the VOC2007 challenge, the best AP ranged by class from 9.4% (boat) to 43.2% (car). For cars and bicycles, precision stayed near 100% up to 15–20% recall and then dropped sharply. The paper suggests that only typical views of objects (such as cars seen from the side) were detected reliably.

Later, R-CNN greatly improved detection accuracy with CNN features, and VOC mAP rose within a short time.

PaperModelTraining dataEvaluationmAP
Girshick et al. (2014)R-CNN (with box regression)VOC2007 trainvalVOC2007 test58.5%
Girshick et al. (2014)R-CNN (with box regression)VOC2012 trainvalVOC2012 test53.3%
Ren et al. (2015)Faster R-CNN (VGG-16)VOC2007 and 2012 trainval (07+12)VOC2007 test73.2%
Ren et al. (2015)Faster R-CNN (VGG-16)COCO and 07+12VOC2007 test78.8%
Ren et al. (2015)Faster R-CNN (VGG-16)VOC2007 trainval+test and 2012 trainval (07++12)VOC2012 test70.4%

As the table shows, deep learning detection papers commonly use two fixed protocols: "train on 07+12, evaluate on VOC2007 test" and "train on 07++12, score VOC2012 test on the evaluation server." The R-CNN paper states that, following the VOC guidelines, all design choices were made on VOC2007, and results were submitted to the VOC2012 evaluation server only once each.

The VOC2012 segmentation data is also used to compare semantic segmentation models (which predict a class for every pixel) by mIoU.

The focus of detection benchmarks later moved to COCO, which has more objects and categories and also evaluates localization accuracy. COCO was built to include all 20 VOC classes. Because it is small and quick to run, VOC is still used as a testbed for detection and segmentation methods.

Practical notes

License: VOC images were collected from Flickr, and their use is subject to Flickr's terms of use. During the challenge, image provenance such as the photographer was withheld.

VOC images were not taken by the organizers; they are photos posted by Flickr users. They are intended for research comparisons. Before redistributing the images or using them as training data for a product, check Flickr's terms of use and the conditions of each image.

Match the year and the split: each VOC year is a separate dataset. VOC2012 classification/detection data uses images from 2008–2011 and excludes VOC2007 images, but the segmentation trainval set also includes images from 2007. VOC2012 classification/detection data is also identical to the 2011 release. When comparing numbers across papers, match both the training data (07, 07+12, 07++12, etc.) and the evaluation data (VOC2007 test or VOC2012 test).

Different AP computations: the 11-point AP of VOC2007 and the area-based AP of VOC2010 and later give slightly different values for the same detections. The VOC2007 development kit computes 11-point AP, and the VOC2010 and later kits compute the area. Other tools may use a different default, so state which one was used.

Overlap with pretraining data: the R-CNN paper reports near-duplicate images between the ILSVRC 2012 train/val sets (ImageNet) and the VOC test sets: 38 images (under 1%) in VOC2007 test and about 1.5% in VOC2012 test. The effect is considered small, but when collecting Flickr photos from outside for training, watch for overlap with the test set.

Class and seasonal bias: the person class is especially large, while classes such as sheep and bus were hard to collect. VOC2007 was also gathered in January 2007 from search results sorted by recency, so it contains more Christmas and winter photos (from VOC2008, random dates were added to the queries to prevent this).

Small scale: even VOC2012 trainval has only about 12,000 images, which is not enough to train a large model from scratch. The usual approach is to pretrain on ImageNet or COCO and then fine-tune.

Comparison with similar datasets

The datasets commonly used for object detection compare as follows.

DatasetImagesCategoriesObjects per imageAnnotation typesDetection metric
PASCAL VOC (2012)Flickr photos, 11,540 train/val202.3Boxes, flags such as difficulty, masks for some images (class and object), boxes for a person's head/hands/feet, person actionsAP (IoU 0.5) averaged over 20 classes
COCO (2017)Flickr photos, about 118k train80 (object annotations)7.7Boxes, per-object masks (crowds as one region), 17 human keypoints, 5 captionsAP (10 IoU levels from 0.50 to 0.95) averaged over 80 classes; AP50, AP75, by size
ImageNet (ILSVRC detection)Photos, 400k2003.0 (val)BoxesAP (IoU 0.5 by default)

(Objects per image are the counts reported in the COCO paper.)

Rules of thumb for choosing:

  • To try detection or segmentation methods cheaply, or compare with older papers, use VOC mAP (train on 07+12, evaluate on VOC2007 test).
  • To compare with current research, or evaluate localization accuracy and small-object detection, report COCO AP.
  • For semantic segmentation, VOC2012 mIoU is one of the standard benchmarks.

PyTorch example

Show code
python
import torch
from torch.utils.data import DataLoader
from torchvision import datasets, transforms

"""
Load PASCAL VOC with torchvision
year is '2007' to '2012'. image_set is 'train', 'val', or 'trainval' ('test' only for 2007, whose test annotations are public)
download=True fetches the data, but the host server is sometimes down, so placing already-downloaded files in root is more reliable
"""

root = './data'

VOC_CLASSES = ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow',
               'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa',
               'train', 'tvmonitor']

# Detection: returns (image, annotation XML parsed into a dict)
det = datasets.VOCDetection(root, year='2007', image_set='trainval', transform=transforms.ToTensor())
image, target = det[0]
obj = target['annotation']['object'][0]
print(len(det))                                   # 5011
print(obj['name'], obj['bndbox'], obj['difficult'])  # class name, {'xmin': ..., 'ymin': ..., 'xmax': ..., 'ymax': ...}, '0' or '1' (all values are strings)


def to_boxes(target):
  """Convert the XML dict into tensors of boxes [x1, y1, x2, y2], labels 0-19, and difficult flags"""
  boxes, labels, difficult = [], [], []
  for o in target['annotation']['object']:
    b = o['bndbox']
    # VOC coordinates put the top-left pixel at (1, 1), so subtract 1 for 0-based indexing
    boxes.append([float(b['xmin']) - 1, float(b['ymin']) - 1, float(b['xmax']) - 1, float(b['ymax']) - 1])
    labels.append(VOC_CLASSES.index(o['name']))
    difficult.append(int(o['difficult']))
  return torch.tensor(boxes), torch.tensor(labels), torch.tensor(difficult, dtype=torch.bool)


# Segmentation: returns (image, PIL image of per-pixel classes). Values are 0 (background) to 20; 255 is void
seg = datasets.VOCSegmentation(root, year='2012', image_set='train')
img, mask = seg[0]


def to_mask_tensor(mask):
  m = torch.as_tensor(list(mask.getdata()), dtype=torch.long).view(mask.size[1], mask.size[0])
  return m                                        # set ignore_index=255 in the training loss to ignore void

# criterion = torch.nn.CrossEntropyLoss(ignore_index=255)


def voc07_ap(recall, precision):
  """VOC2007 11-point AP. recall and precision are the values at each rank when sorted by confidence (1-D tensors)"""
  ap = 0.0
  for t in torch.linspace(0, 1, 11):
    p = precision[recall >= t]
    ap += (p.max().item() if p.numel() > 0 else 0.0) / 11   # max precision at recall >= t
  return ap

FAQ

Q. Should I use VOC2007 or VOC2012?
A.

To compare with detection papers, the most common protocol is training on 07+12 (VOC2007 and 2012 trainval) and evaluating on VOC2007 test, because the VOC2007 test annotations are public and results can be computed locally. When a VOC2012 test score is needed, submit results to the evaluation server.

Q. Can `difficult` objects be used for training?
A.

Either way is fine. The development kit documentation also leaves it to participants whether to include them in training. Evaluation ignores difficult objects, so detecting or missing them does not change AP.

Q. Is VOC mAP the same as COCO AP50?
A.

Both are AP at an IoU threshold of 0.5, but they differ in how AP is computed (11 points for VOC2007, area from VOC2010, 101 points for COCO), in how difficult objects and crowds are handled, and in the data itself. The values cannot be compared directly. See the mAP article for details.

References

  1. Everingham, M., Van Gool, L., Williams, C. K. I., Winn, J., & Zisserman, A. (2010). The PASCAL Visual Object Classes (VOC) Challenge. International Journal of Computer Vision, 88(2), 303–338.
  2. Everingham, M., & Winn, J. (2012). The PASCAL Visual Object Classes Challenge 2012 (VOC2012) Development Kit.
  3. The PASCAL Visual Object Classes Challenge 2012 (official page: data, usage rules, and rights).
  4. Girshick, R., Donahue, J., Darrell, T., & Malik, J. (2014). Rich feature hierarchies for accurate object detection and semantic segmentation. CVPR 2014.
  5. Ren, S., He, K., Girshick, R., & Sun, J. (2015). Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. NeurIPS 2015.
  6. Lin, T.-Y., et al. (2014). Microsoft COCO: Common Objects in Context. ECCV 2014.
  7. torchvision.datasets.VOCDetection (PyTorch documentation).