LabelMe v5.11.4 is released: introduce 'reset layout'.

json-to-masks

You need to be a Pro member to access the full content of this.

json-to-masks converts a LabelMe JSON file to mask files.

Diagram showing LabelMe JSON converted to individual mask files per annotation

v0.1.2 (2025-03-28): Supports shape_type="mask".

Usage

As the argument, you can pass either JSON files or directories of JSON files.

labelmetk json-to-masks [OPTIONS] FILES_OR_DIRS...

Example: Convert a JSON file

If you only have a single JSON file, pass it to the command:

labelmetk json-to-masks small_dataset/2011_000003.json

to get mask images:

Generated mask files from a single JSON file conversion

It converts each "group" represented by group_id (in this case 0):

Polygon annotations grouped by group_id in LabelMe
Group ID popup showing annotation group assignment in LabelMe

Example: Convert a directory of JSON files

If you have multiple JSON files in a directory, pass the directory to the command:

labelmetk json-to-masks small_dataset

to get a mask images for each:

Terminal output of json-to-masks command on a directory Generated mask files from directory conversion

Example: Exclude some labels

If you'd like to exclude some of the labels when creating a mask, pass --exclude-labels:

labelmetk json-to-masks small_dataset --exclude-labels __ignore__

You can see the difference from the previous example:

Mask files generated with excluded labels removed

Example: Browse the result in a browser

If you instantly browse the result on a browser, pass --browse (or -b):

labelmetk json-to-masks small_dataset --browse

It will show the output images as a table:

Browser view showing mask results in a table layout

Download an example dataset from:

small_dataset.zip (389KB)