ObjectDetectionAnnotations
Represents a collection of COCO-style object-detection (or instance-segmentation) annotations. Each item is an ObjectDetectionAnnotation (or equivalent dict) with id, image_id, category_id, and optionally segmentation, bbox, area, iscrowd, and score. This datatype is used for object detection and instance segmentation inputs and outputs within the Telekinesis ecosystem.
Field
Required
| Field | Type | Description |
|---|---|---|
annotations | list[dict] | List of annotation dicts; each has id (int), image_id (int), category_id (int); optional segmentation, bbox, area, iscrowd, score. |
Optional
None.
Methods
| Method | Description |
|---|---|
to_list() | Returns a Python list of annotation dicts. Each dict has at least id, image_id, category_id; and optionally segmentation, bbox, area, iscrowd, score. |
Example
From the datatypes examples:
python
from datatypes import datatypes
from loguru import logger
# ------------------------------------------------
# 1. Create ObjectDetectionAnnotations instance
# ------------------------------------------------
annotations = datatypes.ObjectDetectionAnnotations(annotations=[
{
"id": 0,
"image_id": 1,
"category_id": 2,
"segmentation": [[1, 2, 3], [1, 1]],
"bbox": [0, 0, 0, 0],
"area": 0,
"iscrowd": 0,
"score": None,
},
{
"id": 1,
"image_id": 1,
"category_id": 3,
"segmentation": [[4, 5, 6], [1, 1]],
"bbox": [1, 1, 1, 1],
"area": 1,
"iscrowd": 0,
},
])
# ------------------------------------------------
# 2. Access annotations via to_list
# ------------------------------------------------
annotation_list = annotations.to_list()
logger.info("ObjectDetectionAnnotations to_list len={}", len(annotation_list))
logger.info("ObjectDetectionAnnotations to_list first id={}", annotation_list[0]["id"])
logger.info("ObjectDetectionAnnotations to_list first image_id={}", annotation_list[0]["image_id"])
logger.info("ObjectDetectionAnnotations to_list first category_id={}", annotation_list[0]["category_id"])
