Convert LabelMe
to COCO

Import LabelMe, check the labels in the labeling toolbox, export COCO. COCO is the format most detection and segmentation libraries read.

Format differences

LabelMe vs COCO

LabelMe and COCO describe the same objects in different files and notations.

LabelMeCOCO
Annotation filesOne JSON file per image with a shapes list and the image size.One JSON file per dataset (annotations/instances.json) that lists images, annotations and categories.
CoordinatesAbsolute pixels; every shape is a list of points, a rectangle two of its corners.Absolute pixels; bbox is [x, y, width, height], measured from the top-left corner.
ShapesPolygons, rectangles, circles, points, lines, line strips and masks.Boxes, polygons or RLE masks, keypoints and image captions.
ClassesEach shape carries a free-text label; there is no separate class list.A categories list with numeric ids; every annotation points to one with its category_id.

What the conversion changes

Between the formats

  • LabelMe polygons and rectangles map to COCO polygons and boxes.
  • COCO instances hold polygons, boxes, masks and keypoints only: LabelMe lines and single points do not reach instances.json.
  • Free-text LabelMe labels become COCO categories, so merge spelling variants before the export.

Import LabelMe

  • Polygons, rectangles, circles, points, lines, line strips and masks are read.

Export to COCO

  • Polygons, rectangles and bitmap masks become COCO polygons with boxes; keypoint graphs become COCO keypoints.
  • Holes are not kept: Export to COCO mask keeps holes and exports polylines.
  • Every dataset gets its own instances.json, with image and annotation ids starting at 1.
Workflow

Convert LabelMe to COCO in three steps

  1. 01

    Import LabelMe

    Start an import in a Supervisely project and drop in the folder with the images and their LabelMe JSON files: the importer recognises the format (LabelMe 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 COCO.

  3. 03

    Export to COCO

    Open the menu of the project, choose Download via app and run Export to COCO. 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 COCO 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 the LabelMe import created
sly.download_fast(api, project_id=12345, dest_dir="sly_project")
sly.convert.project_to_coco("sly_project", "coco", copy_images=True)

Frequently asked questions.

Can I convert LabelMe to COCO without code?

Yes. Import the data with the LabelMe import, check it in the image labeling toolbox, then export it with Export to COCO. Both start from the Supervisely web interface.

What changes when LabelMe becomes COCO?

LabelMe polygons and rectangles map to COCO polygons and boxes. COCO instances hold polygons, boxes, masks and keypoints only: LabelMe lines and single points do not reach instances.json. Free-text LabelMe labels become COCO categories, so merge spelling variants before the export.

Does COCO use the same coordinates as LabelMe?

Both use absolute pixel coordinates, written differently. LabelMe: Absolute pixels; every shape is a list of points, a rectangle two of its corners. COCO: Absolute pixels; bbox is [x, y, width, height], measured from the top-left corner.

How do LabelMe classes carry over to COCO?

In LabelMe: each shape carries a free-text label; there is no separate class list. In COCO: a categories list with numeric ids; every annotation points to one with its category_id. 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 LabelMe to COCO in Python?

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