COCO JSON format
COCO (Common Objects in Context) is the most widely used annotation format in computer vision. A COCO JSON file has three top-level arrays: images, annotations, and categories.
Each annotation entry includes a bbox ([x, y, width, height] with top-left origin), a segmentation array of polygon coordinate lists, a computed area in pixels, and a category_id referencing the categories array.
RegionKit generates all three arrays from your scene. Rectangles become bbox entries; polygons become segmentation entries. Category IDs are assigned automatically based on the unique labels in your scene.
Framework compatibility
The COCO JSON exported from RegionKit is compatible with all major CV frameworks:
- Detectron2 — use
register_coco_instances()to load directly - MMDetection — pass the JSON path to your dataset config
- Ultralytics YOLOv8 — supported via COCO dataset format in
data.yaml - FiftyOne — load with
fo.types.COCODetectionDataset
COCO vs YOLO: which to use?
COCO JSON is a single file covering all images — better for rich metadata, ecosystem breadth (Detectron2, MMDet, FiftyOne), and instance segmentation tasks.
YOLO TXT uses one file per image — better for Ultralytics-based training pipelines where the file-per-image layout is expected.
Both formats are first-class exports in RegionKit. If your downstream framework supports both, prefer COCO JSON for richer metadata and easier dataset management.
Common COCO mistakes to avoid
Category ID indexing — COCO convention uses 1-based category IDs (not 0-based). RegionKit follows this convention. Check your framework's expectation if you see off-by-one errors.
bbox format — COCO uses [x, y, width, height] (top-left + dimensions), not [x1, y1, x2, y2] (two corners). Converting incorrectly shifts all annotations.
Read the complete format reference in the COCO format guide on the RegionKit blog.