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.
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
}
]
}
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.
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)
import supervision as sv
ds_1 = sv.DetectionDataset.from_coco(
images_directory_path=f"dataset1/train",
annotations_path=f"dataset1/train/_annotations.coco.json",
)
len(ds_1)
# 100
ds_1.classes
# ['dog', 'person']
ds_2 = sv.DetectionDataset.from_coco(
images_directory_path=f"dataset2/train",
annotations_path=f"dataset2/train/_annotations.coco.json",
)
len(ds_2)
# 200
ds_2.classes
# ['cat']
ds_merged = sv.DetectionDataset.merge([ds_1, ds_2])
len(ds_merged)
# 300
ds_merged.classes
# ['cat', 'dog', 'person']
Below, see model architectures that require data in the COCO JSON format when training a new model.
On each page below, you can find links to our guides that show how to plot predictions from the model, and complete other common tasks like detecting small objects with the model.
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.
With Roboflow, you can deploy a computer vision model without having to build your own infrastructure.
Below, we show how to convert data to and from
COCO JSON
. We also list popular models that use the
COCO JSON
data format. Our conversion tools are free to use.
Free data conversion
SOC II Type 2 Compliant
Trusted by 250,000+ developers
Free data conversion
SOC II Type 1 Compliant
Trusted by 250,000+ developers
The
YOLOv8 Pose Estimation
,
DETR
,
YOLOS
,
Mask RCNN
,
EfficientDet
,
Detectron2
,
models all use the
data format.
{
"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
}
]
}