Convert to COCO

The COCO format is widely used in the computer vision community and is supported by many popular frameworks and libraries. COCO format is a complex format that can contain multiple types of annotations. Supervisely supports conversions for instances, keypoints, and captions.

For more information on how to import COCO format data into Supervisely, see the Import from COCO guide.

Converting data using Supervisely Ecosystem Apps

  • Export to COCO. Convert project to COCO format. It is a simple and efficient way to export your project to COCO format.

  • Export COCO Keypoints. App converts Supervisely format project to COCO Keypoints format as a downloadable .tar archive.

Converting data using Supervisely Python SDK

Our Python SDK provides a simple way to convert your data to COCO format, allowing you to convert a Project or Dataset to COCO format. Easily convert your data in one line of code using the Supervisely Python SDK.

Each dataset in the project will be converted to a separate COCO dataset.

It supports the following geometry types: sly.Rectangle, sly.Bitmap, sly.Polygon, sly.GraphNodes.

Enabling the with_captions parameter will include captions in the COCO annotations (if present in the project).

  • Convert a project to COCO format:

# One line of code
sly.convert.to_coco("./sly_project", dest_dir="./result_coco")

# Or using the sly.Project object
project_fs = sly.Project("./sly_project", sly.OpenMode.READ)
project_fs.to_coco("./result_coco")
  • Convert a specific dataset to COCO format:

ds = project_fs.datasets.get("dataset_name")

sly.convert.to_coco(ds, dest_dir="./result_coco", meta=project_fs.meta)
# Or using the sly.Dataset object
ds.to_coco(project_fs.meta, dest_dir="./result_coco")

Last updated

Was this helpful?