logo
×

How to convert Labelbox exports into COCO format

The COCO format is a specific JSON structure dictating how labels and metadata are saved for an image dataset. As a popular format used for model training, Labelbox makes it easy for users to convert Labelbox exports into COCO format.

Try it now: Github

How to use the COCO converter

  • In terminal, run the following:
python3 path/export_to_coco.py -api_key "<API_KEY>"" -project_id "<PROJECT_ID>" -save_to "<PATH_TO_FOLDER"

Note: If -save_to is left blank, then the converted format will be added to the current dictionary.

  • This script will save the result as
{working_directory}/{save_to}/{project_id}_coco_dataset.json

Use the below to map your export to COCO format:

"Info" Section

description = project name   
url = project URL
version = always just "1.0"
year = time of export
contributor = email of whoever created the Labelbox project
date_created = time of export

"Licenses" Section

url = N/A
id = always just "1"
name = N/A

"Images" Section

file_name = data row external ID
date_captured = data row created at value
id = data row ID

"Annotations" Section - covers all object annotations

image_id = data row ID
category_id = defaults to the tool's schemaId encoded value, but checks for nested classes and if any radio / checklist answers exist, pulls the first one
id = annotation feature ID
** All `iscrowd` values are 0 for segmentation masks / polygons

"Categories" Section

All tools and 1st-layer nested classes will populate in the categories section

For polylines, the `max_keypoints` value is found by iterating over all annotations and grabbing the global maximum

For points, the `skeleton` is [0, 0] and `max_keypoints` is 0

Segmentation masks and polygons fall into the segmentation COCO schema

Bounding boxes fall into the bounding box COCO schema

Learn more about Labelbox exports in our documentation.

You can also reach to support@labelbox.com with any questions or feedback on exporting data from Labelbox.