PanopticSegmentationAnnotation
Represents a COCO-style panoptic segmentation for a single image, comprising an image identifier, a labeled mask (pixel-wise segment IDs), and an optional list of segment metadata. Each segment metadata entry is a SegmentInfo (or equivalent dict). This datatype is used for panoptic segmentation inputs and outputs within the Telekinesis ecosystem.
Field
Required
| Field | Type | Description |
|---|---|---|
image_id | int | Image identifier (int). |
labeled_mask | Image or np.ndarray | Label mask; pixel values are segment IDs. Converted to Image if ndarray. Dtype uint16 typical. |
Optional
| Field | Type | Description |
|---|---|---|
segments_info | list[dict] | List of segment dicts with id (int), category_id (int), bbox (array); optionally area, iscrowd. Default []. |
Methods
| Method | Description |
|---|---|
to_dict() | Returns a dictionary with keys: image_id (int), labeled_mask (Image or array), and optionally segments_info (list of dicts with id, category_id, bbox, and optionally area, iscrowd). |
Example
From the datatypes examples:
python
import numpy as np
from datatypes import datatypes
from loguru import logger
# ------------------------------------------------
# 1. Create PanopticSegmentationAnnotation instance
# ------------------------------------------------
annotation = datatypes.PanopticSegmentationAnnotation(
image_id=0,
labeled_mask=np.array([[0, 0, 0], [0, 0, 0], [0, 0, 0]]),
segments_info=[{"id": 0, "category_id": 0, "bbox": np.array([0, 0, 1, 1])}],
)
# ------------------------------------------------
# 2. Access data via to_dict
# ------------------------------------------------
data = annotation.to_dict()
logger.info("PanopticSegmentationAnnotation to_dict image_id={}", data["image_id"])
labeled_mask = data["labeled_mask"]
logger.info("PanopticSegmentationAnnotation to_dict labeled_mask shape={}", labeled_mask.shape if hasattr(labeled_mask, "shape") else len(labeled_mask))
logger.info("PanopticSegmentationAnnotation to_dict segments_info len={}", len(data["segments_info"]))
