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
| Field | Type | Description |
|---|---|---|
id | int | Unique category identifier (int). |
name | str | Category name (str). |
supercategory | str | Supercategory name (str). |
Optional
| Field | Type | Description |
|---|---|---|
isthing | int | Whether the category is a "thing" (1) or "stuff" (0). Default 0. Must be 0 or 1. |
color | list[int] or np.ndarray | RGB color as list or array of 3 integers. Default [0, 0, 0]. |
Methods
| Method | Description |
|---|---|
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"])
