Skip to main content

Converting polygons to bitmasks

The following script converts polygon labels from the source project into Bitmask labels in the target project. The conversion applies to images, videos, image groups, and image sequences. For this conversion to be effective, it is crucial that both the source and target projects are linked to the same dataset. The script is agnostic to which workflow stage the source or target data units are in.
To install the required Python dependencies, run the following command in your terminal:
This script utilizes Typer, allowing you to conveniently insert arguments in your terminal rather than directly into the script.
To execute the script in your terminal, use the following command:
Replace script-name.py with the actual name of your script and respond to the prompted questions during execution. For a non-interactive usage, provide the following parameters:
Replace the placeholders with the appropriate values:
  • script-name.py with the name of your script.
  • <ssh_key_path> with the path to your private access key associated with Encord.
  • <source_project_hash> with the hash of the source project containing the polygon labels.
  • <target_project_hash> with the hash of the target project that will contain the bitmask labels.
For example:
This script is intended for a one-time operation only. Running it more than once will result in duplicate labels.

Converting polygons to bounding boxes

The following script converts polygon labels from the source Project into bounding box labels in the target Project. The conversion applies to images, videos, image groups, and image sequences. For this conversion to be effective, it’s crucial that both the source and target Projects are linked to the same Dataset. The script is agnostic to which Workflow stage the source or target data units are in.
To install the required Python dependencies, run the following command in your terminal:
This script utilizes Typer, allowing you to conveniently insert arguments in your terminal rather than directly into the script.
To execute the script in your terminal, use the following command:
Replace script-name.py with the actual name of your script and respond to the prompted questions during execution. For a non-interactive usage, provide the following parameters:
Replace the placeholders with the appropriate values:
  • script-name.py with the name of your script.
  • <ssh_key_path> with the path to your private access key associated with Encord.
  • <source_project_hash> with the hash of the source project containing the polygon labels.
  • <target_project_hash> with the hash of the target project that will contain the bounding boxes labels.
For example:
This script is intended for a one-time operation only. Running it more than once will result in duplicate labels.