COCO JSON
COCO is a common JSON format used for machine learning because the dataset it was introduced with has become a common benchmark.
Overview
Microsoft released the MS COCO dataset in 2015. It has become a common benchmark dataset for object detection models since then which has popularized the use of its JSON annotation format. You can learn how to create COCO JSON from scratch in our CVAT tutorial.
Unfortunately, COCO format is not anywhere near universal and so you may find yourself needing to convert it to another format for a model (or export to COCO JSON from another format if you happen to be using a model that supports it).
Not to worry, Roboflow is the universal tool for computer vision format conversion and can seamlessly input and output files in COCO JSON format.
Format Description
Below, learn the structure of COCO JSON.
{
"info": {
"year": "2020",
"version": "1",
"description": "Exported from roboflow.ai",
"contributor": "Roboflow",
"url": "https://app.roboflow.ai/datasets/hard-hat-sample/1",
"date_created": "2000-01-01T00:00:00+00:00"
},
"licenses": [
{
"id": 1,
"url": "https://creativecommons.org/publicdomain/zero/1.0/",
"name": "Public Domain"
}
],
"categories": [
{
"id": 0,
"name": "Workers",
"supercategory": "none"
},
{
"id": 1,
"name": "head",
"supercategory": "Workers"
},
{
"id": 2,
"name": "helmet",
"supercategory": "Workers"
},
{
"id": 3,
"name": "person",
"supercategory": "Workers"
}
],
"images": [
{
"id": 0,
"license": 1,
"file_name": "0001.jpg",
"height": 275,
"width": 490,
"date_captured": "2020-07-20T19:39:26+00:00"
}
],
"annotations": [
{
"id": 0,
"image_id": 0,
"category_id": 2,
"bbox": [
45,
2,
85,
85
],
"area": 7225,
"segmentation": [],
"iscrowd": 0
},
{
"id": 1,
"image_id": 0,
"category_id": 2,
"bbox": [
324,
29,
72,
81
],
"area": 5832,
"segmentation": [],
"iscrowd": 0
}
]
}Split and Merge Datasets
With Roboflow supervision, an open source Python package with utilities for completing computer vision tasks, you can merge and split detections in COCO JSON. Read our dedicated guides to learn how to merge and split COCO JSON detections.
Split detections in COCO JSON
import supervision as sv
ds = sv.DetectionDataset.from_coco(
images_directory_path=f"dataset1/train",
annotations_path=f"dataset1/train/_annotations.coco.json",
)
train_ds, test_ds = ds.split(split_ratio=0.7,
random_state=42, shuffle=True)
len(train_ds), len(test_ds)
# (700, 300)Supported Models
Below, see model architectures that require data in the COCO JSON format when training a new model.
- YOLOv8 Pose EstimationKeypoint Detection
YOLOv8 Pose Estimation predicts 17-keypoint human skeletons in real time using the YOLOv8 architecture, deployable via Roboflow Inference on custom datasets.
- DETRObject Detection
DETR is Meta's end-to-end transformer-based object detector that eliminates anchors and NMS, achieving 42.0% AP on COCO using set prediction with attention.
- YOLOSObject Detection
YOLOS applies a Vision Transformer to object detection as a flat sequence without convolutions or anchors, demonstrating ViT transferability to detection tasks.
- Mask R-CNNInstance Segmentation
Mask R-CNN extends Faster R-CNN with a mask prediction branch and RoIAlign, enabling precise instance segmentation alongside object detection in a single model.
- EfficientDetObject Detection
EfficientDet is Google's scalable object detection model using compound scaling and BiFPN, achieving 55.1% AP on COCO across a family of model sizes.
- Detectron2Object Detection
Detectron2 is Meta's PyTorch-based computer vision framework supporting object detection, instance segmentation, keypoint detection, and panoptic segmentation.
Convert Data from COCO JSON
- COCO Run-Length Encoding (RLE)
- CreateML JSON
- Florence-2
- Google Cloud AutoML Vision CSV
- meituan/yolov6
- Multiclass Classification CSV
- OpenAI CLIP Classification
- OpenAI GPT-4o Object Detection JSONL
- PaliGemma JSONL
- Pascal VOC XML
- RetinaNet Keras CSV
- Sagemaker GroundTruth Manifest
- Scaled-YOLOv4 TXT
- Segment Anything 2
- Tensorflow Object Detection CSV
- Tensorflow TFRecord
- YOLO Darknet TXT
- YOLO Keras TXT
- YOLOv10 PyTorch TXT
- YOLOv11 PyTorch TXT
- YOLOv12 PyTorch TXT
- YOLOv4 PyTorch TXT
- YOLOv5 Oriented Bounding Boxes
- YOLOv5 PyTorch TXT
- YOLOv7 PyTorch TXT
- YOLOv8 Oriented Bounding Boxes
- YOLOv8 PyTorch TXT
- YOLOv9 PyTorch TXT
Convert Data to COCO JSON
- Cogniac
- CreateML JSON
- Google Cloud AutoML Vision CSV
- IBM Cloud Annotations JSON
- Kaggle Wheat CSV
- LabelBox JSON
- LabelBox Video JSON
- LabelMe JSON
- Marmot XML
- Multiclass Classification CSV
- OIDv4 TXT
- OpenImages CSV
- Pascal VOC XML
- RetinaNet Keras CSV
- Sagemaker GroundTruth Manifest
- Scale AI JSON
- SuperAnnotate JSON
- Supervisely JSON
- Tensorflow Object Detection CSV
- Udacity TXT
- Unity Perception JSON
- VGG Image Annotator CSV
- VGG Image Annotator JSON
- VoTT CSV
- VoTT JSON
- YOLO
- YOLO Darknet TXT
- YOLO Keras TXT
- YOLOv8 PyTorch TXT