Sign in Get started

Export & conversion

Export a dataset to any of 12 annotation formats, or convert COCO, YOLO and Pascal VOC annotations offline with no API call and no extra library.

View as Markdown
On this page

Export builds a ZIP of a dataset in any of 12 formats; training reads exports. Conversion turns COCO, YOLO and Pascal VOC annotations into Pictograph’s and back, locally.

Export a dataset

from pictograph import Client, Export

client = Client()
export: Export = client.exports.create(
    dataset="road-signs",
    name="road-signs-coco",
    format="coco",
    include_images=True,
    wait=True,
)
client.exports.download(
    dataset="road-signs",
    export=export.name,
    output_path="road-signs-coco.zip",
)
pictograph exports create road-signs --name road-signs-coco -f coco --include-images
pictograph exports download road-signs road-signs-coco -o ./road-signs-coco.zip

Every format and what it carries: Exports. A pictograph export also records each image’s size and split (format).

Convert annotations offline

Source: formats/

from pictograph.formats import from_coco, to_yolo

imp = from_coco("instances_val.json")  # CocoImport(annotations, class_names)

yolo_txt = to_yolo(
    imp.annotations["a.jpg"],
    imp.class_names,
    image_width=640,
    image_height=480,
)
Function Reads or writes
from_coco Boxes, polygons and keypoints; a multi-part object stays one polygon
to_coco Boxes, polygons and keypoints (no RLE masks)
from_yolo / to_yolo Detection and segmentation labels
from_pascal_voc / to_pascal_voc Per-image XML
trace_mask One instance mask, traced into one polygon with its holes

Tracing an RLE mask needs the inference extra; without it, the mask is listed in imp.unconverted. to_coco writes no RLE, so other tools read a polygon’s holes as filled; for exact holes, export to COCO instead.

Import a file onto a dataset

Each annotation is matched to its image by filename, and missing classes are created. The images must already be in the dataset.

from pictograph import AnnotationImportReport, Client

client = Client()
report: AnnotationImportReport = client.annotations.import_coco(
    dataset="road-signs",
    coco="instances_val.json",
)
print(report.images_saved, "images annotated;", len(report.unmatched_files), "unmatched")
pictograph annotations import-coco road-signs instances_val.json

import_pascal_voc and import_yolo work the same way.

Copied to clipboard