Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Obss Sahi COCO Classes

From Leeroopedia


Knowledge Sources
Domains Object_Detection, Dataset
Last Updated 2026-02-08 12:00 GMT

Overview

Constant list defining the 91 COCO dataset object category names used for mapping category IDs to human-readable labels.

Description

COCO_CLASSES is a module-level constant in sahi.constants that provides the canonical mapping from COCO category indices to class names. The list contains 93 entries: a __background__ class at index 0, 80 valid object categories (person, car, dog, etc.), and several N/A placeholder entries for unused category IDs. This matches the standard COCO 2017 category layout where category IDs are not contiguous.

Usage

Import this constant when you need to convert COCO category IDs (0-90) into human-readable class names for display, filtering, or validation purposes within the SAHI detection pipeline.

Code Reference

Source Location

Signature

COCO_CLASSES = [
    "__background__",
    "person",
    "bicycle",
    "car",
    # ... 80 COCO categories + N/A placeholders ...
    "toothbrush",
]

Import

from sahi.constants import COCO_CLASSES

I/O Contract

Inputs

Name Type Required Description
(none) This is a constant; no inputs required

Outputs

Name Type Description
COCO_CLASSES list[str] 93-element list mapping indices to COCO category names

Usage Examples

Looking Up a Category Name

from sahi.constants import COCO_CLASSES

# Get category name for COCO category ID 1
print(COCO_CLASSES[1])  # "person"

# Get category name for COCO category ID 3
print(COCO_CLASSES[3])  # "car"

# Filter out N/A entries
valid_classes = [c for c in COCO_CLASSES if c != "N/A" and c != "__background__"]
print(f"Number of valid COCO classes: {len(valid_classes)}")  # 80

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment