- URL of the mask PNG, with each pixel being a
uint8ranging from 0-255 - List of
Segmentsmapping eachuint8value of the mask to an instance/class - Reference ID of the item to which to apply the prediction
- Annotation ID, an optional unique (per dataset item) key to refer to the prediction
Segment-level metadata.
Segmentation Masks
Nucleus expects masks to be image height by image widthuint8 arrays saved in PNG format. Each pixel value should range from [0, N), where N is the number of possible instances (for panoptic and instance segmentation) or classes (for semantic segmentation).
Your segmentation masks must be accessible to Scale via remote URL (e.g. s3://, gs://, signed URL) or path to a local file.
For more information, check out our Python SDK reference for SegmentationPredictions.
Segments
After constructing mask PNGs with corresponding pixel values, the next step is to tell Nucleus how to map pixel values to instances/classes in your taxonomy.
The Nucleus API uses Segments to define this mapping from pixel value to instance/class. This provides the flexibility to work with panoptic, instance, or semantic segmentation masks as needed.
Concretely, you will need a Segment for each unique pixel value in the mask. This means one Segment per instance for panoptic and instance segmentation, or per class for semantic segmentation.
Each Segment can also house arbitrary key-value metadata. In particular for predictions, it may be helpful to include model confidence or PDF value for further querying and analysis.
For more information, check out our Python SDK reference for Segments.
Example
Suppose we are applying a segmentation mask to the following image. In this case, we are working with panoptic segmentation.) with panoptic mask + object detection boxes.](https://mintcdn.com/scale-full-docs/0LAM4ucKzAG9Dmk0/assets/nucleus/267b266-segmentation-annotations-example.webp?fit=max&auto=format&n=0LAM4ucKzAG9Dmk0&q=85&s=720c0369dece436bb84dc890cb7d27f2)
Image from MSCOCO (original) with panoptic mask + object detection boxes.
Segments to map each pixel value in the mask PNG to a class instance as follows:
In code, this is as simple as:
- 0, 1, 2, 3, 4, 5: Background
- 6: Person
- 7: Handbag
- 8: Bird 1
- 9: Bird 2
- 10: Bird 3
- 0: Background
- 1: Building
- 2: Tree
- 3: Fence
- 4: Wall
- 5: Pavement
- 6: Person
- 7: Handbag
- 8, 9, 10: Bird