Convert PNG masks
to Supervisely

Converting PNG masks to Supervisely brings your labels into a format that keeps every shape, tag and class, ready to review, relabel and export to any other format.

Format differences

PNG masks vs Supervisely

PNG masks are segmentation labels drawn as images: a semantic mask per image in which every pixel value is a class, or a black-and-white mask per object for instance segmentation.

PNG masksSupervisely
Annotation filesOne PNG per image in masks_machine/ (semantic) or one per object in masks_instance/<image>/ (instance), with obj_class_to_machine_color.json.One JSON file per image (ann/<image>.json) in each dataset folder, and one meta.json for the project.
CoordinatesPixels: a mask has the size of its image, and each of its pixels is set or not.Absolute pixels; a rectangle is stored as its top-left and bottom-right points.
ShapesPixel masks only, semantic or instance; no boxes or polygons.Rectangles, polygons, polylines, points, bitmap masks, keypoint graphs, alpha masks and 2D cuboids.
Classesobj_class_to_machine_color.json maps every class to its pixel value; an instance mask is named after its class.Classes are defined in meta.json with a name, a shape and a colour; tags can sit on images and on objects.

What the conversion changes

Import PNG masks

  • obj_class_to_machine_color.json is required: it maps pixel values to classes.
  • In a semantic mask, all the pixels of a class become one bitmap label.
  • Every instance mask becomes one label of the class its file is named after.

Export to Supervisely

  • Every imported label keeps its shape, class and tags in Supervisely JSON.
Workflow

Convert PNG masks to Supervisely in three steps

  1. 01

    Import PNG masks

    Upload your PNG masks folder or archive to Supervisely and run Import images with masks from the Ecosystem: it creates a project with the images and labels (PNG masks import guide).

  2. 02

    Review in the labeling toolbox

    Open the project in the image labeling toolbox to check classes and fix labels.

  3. 03

    Export to Supervisely

    Open the menu of the project, choose Download via app and run Export to Supervisely format. 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, the format the Export to Supervisely format app writes.

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 Import images with masks created
sly.download_fast(api, project_id=12345, dest_dir="sly_project")

Frequently asked questions.

Can I convert PNG masks to Supervisely without code?

Yes. Import the data with Import images with masks, check it in the image labeling toolbox, then export it with Export to Supervisely format. Both start from the Supervisely web interface.

What changes when PNG masks becomes Supervisely?

obj_class_to_machine_color.json is required: it maps pixel values to classes. In a semantic mask, all the pixels of a class become one bitmap label. Every instance mask becomes one label of the class its file is named after.

Does Supervisely use the same coordinates as PNG masks?

No. PNG masks uses pixel masks, Supervisely absolute pixel coordinates. PNG masks: Pixels: a mask has the size of its image, and each of its pixels is set or not. Supervisely: Absolute pixels; a rectangle is stored as its top-left and bottom-right points. The export does the conversion.

How do PNG masks classes carry over to Supervisely?

In PNG masks: obj_class_to_machine_color.json maps every class to its pixel value; an instance mask is named after its class. In Supervisely: classes are defined in meta.json with a name, a shape and a colour; tags can sit on images and on objects. 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 PNG masks to Supervisely in Python?

After the import, the Python SDK downloads the project as Supervisely JSON, the format the Export to Supervisely format app writes. See the SDK export tutorial.