Convert YOLO
to Pascal VOC

Import YOLO, check the labels in the labeling toolbox, export Pascal VOC. Pascal VOC is the format that classic detection tools and the torchvision VOC loaders read.

Format differences

YOLO vs Pascal VOC

YOLO and Pascal VOC describe the same objects in different files and notations.

YOLOPascal VOC
Annotation filesOne TXT file per image in labels/, and a YAML file (data_config.yaml) with the class names and the train and val folders.One XML file per image in Annotations/, PNG masks in SegmentationClass/ and SegmentationObject/, image lists in ImageSets/.
CoordinatesNormalized to 0–1; a box is x_center, y_center, width, height.Absolute pixels; a box is xmin, ymin, xmax, ymax.
ShapesBoxes for detection, polygons for segmentation, keypoints for pose: one task per label set.Boxes in the XML; semantic and instance segmentation as PNG masks.
ClassesEach line starts with a zero-based class index; the names are listed in the YAML file.The class name is written in each XML object; colors.txt, added by Supervisely, maps classes to mask colours.

What the conversion changes

Between the formats

  • Normalized YOLO boxes become pixel corner boxes in one XML file per image.
  • YOLO segmentation polygons are drawn into the VOC class and object masks.

Import YOLO

  • Detection lines become rectangles, segmentation lines polygons and pose lines keypoints.
  • Without data_config.yaml the default COCO class names are used.
  • The images are split into train and val datasets and tagged to match.

Export to Pascal VOC

  • Polygons, bitmaps and rectangles are exported, other shapes are skipped; only polygons and bitmaps are drawn into the masks.
  • Image tags other than train and val are dropped.
  • Without train and val tags the images are split 80/20.
Workflow

Convert YOLO to Pascal VOC in three steps

  1. 01

    Import YOLO

    Upload your YOLO folder or archive to Supervisely and run Convert YOLO v5 to Supervisely format from the Ecosystem: it creates a project with the images and labels (YOLO import guide).

  2. 02

    Review in the labeling toolbox

    Open the project in the image labeling toolbox to check classes and fix labels before they go to Pascal VOC.

  3. 03

    Export to Pascal VOC

    Open the menu of the project, choose Download via app and run Export to Pascal VOC. The archive appears in Tasks and Team Files.

Run this conversion on your own data in a free account, or let us walk your team through it.

Python SDK

Or in a few lines of Python

After the import, the Python SDK downloads the project as Supervisely JSON and writes Pascal VOC on your disk.

Install it with pip install supervisely.

SDK export tutorial
convert.py
import supervisely as sly

# SERVER_ADDRESS and API_TOKEN come from the environment
api = sly.Api.from_env()
# ID of the project Convert YOLO v5 to Supervisely format created
sly.download_fast(api, project_id=12345, dest_dir="sly_project")
sly.convert.project_to_pascal_voc("sly_project", "pascal_voc")

Frequently asked questions.

Can I convert YOLO to Pascal VOC without code?

Yes. Import the data with Convert YOLO v5 to Supervisely format, check it in the image labeling toolbox, then export it with Export to Pascal VOC. Both start from the Supervisely web interface.

What changes when YOLO becomes Pascal VOC?

Normalized YOLO boxes become pixel corner boxes in one XML file per image. YOLO segmentation polygons are drawn into the VOC class and object masks. Detection lines become rectangles, segmentation lines polygons and pose lines keypoints.

Does Pascal VOC use the same coordinates as YOLO?

No. YOLO uses coordinates divided by the image size, Pascal VOC absolute pixel coordinates. YOLO: Normalized to 0–1; a box is x_center, y_center, width, height. Pascal VOC: Absolute pixels; a box is xmin, ymin, xmax, ymax. The export does the conversion.

How do YOLO classes carry over to Pascal VOC?

In YOLO: each line starts with a zero-based class index; the names are listed in the YAML file. In Pascal VOC: the class name is written in each XML object; colors.txt, added by Supervisely, maps classes to mask colours. The class names stay the same on the way through Supervisely, so rename or merge classes in the project before you export.

Can I convert YOLO to Pascal VOC in Python?

After the import, the Python SDK downloads the project as Supervisely JSON and writes Pascal VOC on your disk. See the SDK export tutorial.