Categories
Represents a collection of category definitions for annotations (e.g. COCO-style). Each element is a Category (or equivalent dict) with required id, name, supercategory and optionally isthing and color. This datatype is used with object detection, segmentation, and geometry annotations within the Telekinesis ecosystem.
Field
Required
| Field | Type | Description |
|---|---|---|
categories | list[dict] | List of category dicts; each has id (int), name (str), supercategory (str); optional isthing (int 0/1), color (list of 3 ints). |
Optional
None.
Methods
| Method | Description |
|---|---|
to_list() | Returns a Python list of category dicts. Each dict has required id, name, supercategory and optionally isthing (0 or 1), color (list of 3 ints). |
Example
From the datatypes examples:
python
from datatypes import datatypes
from loguru import logger
# ------------------------------------------------
# 1. Create Categories instance
# ------------------------------------------------
categories = datatypes.Categories(categories=[
{
"id": 0,
"name": "person",
"supercategory": "human",
"color": [220, 85, 96],
"isthing": 1,
},
{
"id": 1,
"name": "bicycle",
"supercategory": "vehicle",
"color": [0, 255, 0],
"isthing": 1,
},
])
# ------------------------------------------------
# 2. Access categories via to_list
# ------------------------------------------------
category_list = categories.to_list()
logger.info("Categories to_list len={}", len(category_list))
logger.info("Categories to_list first id={}", category_list[0]["id"])
logger.info("Categories to_list first name={}", category_list[0]["name"])
logger.info("Categories to_list second name={}", category_list[1]["name"])
