Implementation:Obss Sahi COCO Classes
| 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
- Repository: Obss_Sahi
- File: sahi/constants.py
- Lines: 1-93
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