Skip to content

ObjectDetectionAnnotation

Represents a single COCO-style object-detection or instance-segmentation annotation for one object. Required fields are id, image_id, and category_id; optional fields include segmentation, bbox, area, iscrowd, and score. This datatype is used as the schema for each element in ObjectDetectionAnnotations within the Telekinesis ecosystem.

Field

Required

FieldTypeDescription
idintAnnotation identifier (int).
image_idintImage identifier (int).
category_idintCategory identifier (int).

Optional

FieldTypeDescription
segmentationlist[list[float]], list[np.ndarray], or dictPolygons (list of polygons) or RLE dict with counts and size. Default [].
bboxlist[int] or np.ndarrayBounding box [x, y, width, height]; length 4. Default [0, 0, 0, 0].
areafloatArea of the segment. Default 0.0.
iscrowdintWhether the annotation is a crowd region. Default 0.
scorefloat or NoneDetection or confidence score. Default None.

Methods

MethodDescription
to_dict()Returns a dictionary with keys: id, image_id, category_id, segmentation, bbox, area, iscrowd, score.

Example

From the datatypes examples:

python
from datatypes import datatypes
from loguru import logger

# ------------------------------------------------
# 1. Create ObjectDetectionAnnotation instance
# ------------------------------------------------
ann = datatypes.ObjectDetectionAnnotation(
    id=1,
    image_id=0,
    category_id=1,
    segmentation=[[10.0, 10.0, 50.0, 10.0, 50.0, 50.0, 10.0, 50.0]],
    bbox=[10, 10, 40, 40],
    area=1600.0,
    iscrowd=0,
)

# ------------------------------------------------
# 2. Access data via to_dict
# ------------------------------------------------
d = ann.to_dict()
logger.info("ObjectDetectionAnnotation id={}", d["id"])
logger.info("ObjectDetectionAnnotation image_id={}", d["image_id"])
logger.info("ObjectDetectionAnnotation category_id={}", d["category_id"])
logger.info("ObjectDetectionAnnotation bbox={}", d["bbox"])
logger.info("ObjectDetectionAnnotation area={}", d["area"])
logger.info("ObjectDetectionAnnotation score={}", d.get("score"))