Pascal VOC annotation format

An XML file of labeled boxes for every image, segmentation masks as PNG by class and by object, and text lists of the train and val images.

Data
Images
Labels
BoxesMasks
Files
.xml, .png
Import / export
Yes / Yes
The format

What is the Pascal VOC format?

Pascal VOC is the format of the PASCAL Visual Object Classes project, which published standardised image datasets for object class recognition with tools to read their annotations, and ran challenges from 2005 to 2012.

Each image has an XML file in Annotations with the image size and an <object> per instance: the class <name> and a <bndbox> with xmin, ymin, xmax and ymax in pixels. Segmentation is stored as PNG masks: SegmentationClass colors pixels by class and SegmentationObject by instance. ImageSets lists which images belong to train and val.

Files

Folder structure and an example

Folder structure for import
VOCdevkit
└── VOC2012
    ├── Annotations
    ├── ImageSets
    │   ├── Main
    │   └── Segmentation
    ├── JPEGImages
    ├── SegmentationClass
    ├── SegmentationObject
    └── colors.txt
Annotations/IMG_1836.xml
<annotation>
  <filename>IMG_1836.jpg</filename>
  <size>
    <width>1067</width>
    <height>800</height>
    <depth>3</depth>
  </size>
  <segmented>1</segmented>
  <object>
    <name>lemon</name>
    <bndbox>
      <xmin>752</xmin>
      <ymin>421</ymin>
      <xmax>1009</xmax>
      <ymax>588</ymax>
    </bndbox>
  </object>
</annotation>
colors.txt (class colors of the masks, added by Supervisely)
neutral 224 224 192
kiwi 255 0 0
lemon 81 198 170
In and out

Import and export Pascal VOC in Supervisely

Import Pascal VOC into Supervisely

  • Import data (Auto Import)

    Reads .xml boxes and .png segmentation masks from a VOCdevkit folder or archive.

  • Import Pascal VOC

    Imports the original Pascal VOC datasets or a custom one from Team Files. A custom dataset needs colors.txt; Action and Layout image sets are not supported.

Export from Supervisely to Pascal VOC

  • Export to Pascal VOC

    Exports polygon, bitmap and rectangle classes: boxes to XML, polygons and bitmaps also to SegmentationClass and SegmentationObject masks, with colors.txt. Other shapes and other image tags are skipped.

  • Python SDK

    sly.convert.project_to_pascal_voc() converts a downloaded project.

All apps are in the Ecosystem, under Import and Export. Every project is stored in Supervisely JSON in between.

Conversion

Converting Pascal VOC to and from Supervisely JSON

Pascal VOCSupervisely JSONNotes
<object><name>class titleOne class per object name.
<bndbox> xmin ymin xmax ymaxrectangle [[xmin, ymin], [xmax, ymax]]Pixel corners on both sides.
SegmentationObject PNGbitmap, one per instanceThe class of each instance comes from its color in SegmentationClass and colors.txt.
SegmentationClass, SegmentationObject PNGpolygon, bitmapOn export, polygons and bitmaps are drawn into both masks.
ImageSets/Main train, valimage tags train, valWithout these tags the export splits the images 80% train, 20% val.