Skip to content

Category

Represents a single category in a dataset (e.g. COCO-style). Each category has required id, name, and supercategory, and optional isthing and color. This datatype is used as the schema for each element in Categories and in annotation workflows within the Telekinesis ecosystem.

Field

Required

FieldTypeDescription
idintUnique category identifier (int).
namestrCategory name (str).
supercategorystrSupercategory name (str).

Optional

FieldTypeDescription
isthingintWhether the category is a "thing" (1) or "stuff" (0). Default 0. Must be 0 or 1.
colorlist[int] or np.ndarrayRGB color as list or array of 3 integers. Default [0, 0, 0].

Methods

MethodDescription
to_dict()Returns a dictionary with keys: id, name, supercategory, isthing, color.

Example

From the datatypes examples:

python
from datatypes import datatypes
from loguru import logger

# ------------------------------------------------
# 1. Create Category instance
# ------------------------------------------------
category = datatypes.Category(
    id=1,
    name="object",
    supercategory="thing",
    isthing=1,
    color=[255, 0, 0],
)

# ------------------------------------------------
# 2. Access data via to_dict
# ------------------------------------------------
d = category.to_dict()
logger.info("Category id={}", d["id"])
logger.info("Category name={}", d["name"])
logger.info("Category supercategory={}", d["supercategory"])
logger.info("Category isthing={}", d["isthing"])
logger.info("Category color={}", d["color"])