Convert Supervisely
to PNG masks

Exporting a Supervisely project to PNG masks gets your labels into pixel masks that any segmentation training code can load.

Format differences

Supervisely vs PNG masks

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. A Supervisely project holds every shape the platform can draw, so the conversion is about what PNG masks can hold.

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

What the conversion changes

Export to PNG masks

  • The archive holds the images, their Supervisely JSON and the masks you choose: human (class colours), machine (class indexes), instance and semantic RGB masks.
  • Machine masks look black in an image viewer: their pixel values are class indexes, background is 0, mapped in obj_class_to_machine_color.json.
Workflow

Convert Supervisely to PNG masks in three steps

  1. 01

    Import Supervisely

    Upload the project folder or archive to Supervisely and run Import images in Supervisely format from the Ecosystem: it creates a project with the images and labels (Supervisely 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 PNG masks.

  3. 03

    Export to PNG masks

    Open the menu of the project, choose Download via app and run Export as masks. 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

The SDK has no PNG masks writer: it uploads a Supervisely project from your disk, and the export app does the rest.

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()
project_id, name = sly.Project.upload("sly_project", api, workspace_id=123)
# Then run Export as masks on this project

Frequently asked questions.

Can I convert Supervisely to PNG masks without code?

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

What changes when Supervisely becomes PNG masks?

The archive holds the images, their Supervisely JSON and the masks you choose: human (class colours), machine (class indexes), instance and semantic RGB masks. Machine masks look black in an image viewer: their pixel values are class indexes, background is 0, mapped in obj_class_to_machine_color.json.

Does PNG masks use the same coordinates as Supervisely?

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

How do Supervisely classes carry over to PNG masks?

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

The SDK has no PNG masks writer: it uploads a Supervisely project from your disk, and the export app does the rest. See the SDK export tutorial.