Convert CVAT
to COCO
Import CVAT, check the labels in the labeling toolbox, export COCO. COCO is the format most detection and segmentation libraries read.
CVAT vs COCO
CVAT and COCO describe the same objects in different files and notations.
| CVAT | COCO | |
|---|---|---|
| Annotation files | One annotations.xml per task, with an image element for every image. | One JSON file per dataset (annotations/instances.json) that lists images, annotations and categories. |
| Coordinates | Absolute pixels; a box is xtl, ytl, xbr, ybr, a polygon or polyline a list of points. | Absolute pixels; bbox is [x, y, width, height], measured from the top-left corner. |
| Shapes | Boxes, polygons, polylines, points, ellipses, cuboids, masks and skeletons, with attributes. | Boxes, polygons or RLE masks, keypoints and image captions. |
| Classes | Labels and their attributes are defined in the task meta; every shape names its label. | A categories list with numeric ids; every annotation points to one with its category_id. |
What the conversion changes
Between the formats
- CVAT boxes and polygons become COCO boxes and polygons, and CVAT labels become categories.
- COCO instances have no standard field for CVAT attributes.
Import CVAT
- Export from CVAT as CVAT for images 1.1, for images and videos alike.
- Cuboids and ellipses are skipped.
- A CVAT project with both images and videos becomes two Supervisely projects; CVAT to Supervisely Migration Tool copies projects straight from a CVAT server.
Export to COCO
- Polygons, rectangles and bitmap masks become COCO polygons with boxes; keypoint graphs become COCO keypoints.
- Holes are not kept: Export to COCO mask keeps holes and exports polylines.
- Every dataset gets its own instances.json, with image and annotation ids starting at 1.
Convert CVAT to COCO in three steps
- 01
Import CVAT
Upload your CVAT folder or archive to Supervisely and run Import CVAT from the Ecosystem: it creates a project with the images and labels.
- 02
Review in the labeling toolbox
Open the project in the image labeling toolbox to check classes and fix labels before they go to COCO.
- 03
Export to COCO
Open the menu of the project, choose Download via app and run Export to COCO. The archive appears in Tasks and Team Files.
Apps in the Supervisely Ecosystem
ImportImport CVATImports images and videos with annotations in CVAT format.Open in Ecosystem
Import · from a CVAT serverCVAT to Supervisely Migration ToolConverts and copies several CVAT projects into Supervisely at once.Open in Ecosystem
ExportExport to COCOConverts a Supervisely project to COCO and prepares a tar archive for download.Open in Ecosystem
Export · masks with holesExport to COCO maskConverts Supervisely annotations to COCO RLE masks and keeps their holes.Open in Ecosystem
Run this conversion on your own data in a free account, or let us walk your team through it.
Or in a few lines of Python
After the import, the Python SDK downloads the project as Supervisely JSON and writes COCO on your disk.
Install it with pip install supervisely.
import supervisely as sly
# SERVER_ADDRESS and API_TOKEN come from the environment
api = sly.Api.from_env()
# ID of the project Import CVAT created
sly.download_fast(api, project_id=12345, dest_dir="sly_project")
sly.convert.project_to_coco("sly_project", "coco", copy_images=True)Frequently asked questions.
Can I convert CVAT to COCO without code?
Yes. Import the data with Import CVAT, check it in the image labeling toolbox, then export it with Export to COCO. Both start from the Supervisely web interface.
What changes when CVAT becomes COCO?
CVAT boxes and polygons become COCO boxes and polygons, and CVAT labels become categories. COCO instances have no standard field for CVAT attributes. Export from CVAT as CVAT for images 1.1, for images and videos alike.
Does COCO use the same coordinates as CVAT?
Both use absolute pixel coordinates, written differently. CVAT: Absolute pixels; a box is xtl, ytl, xbr, ybr, a polygon or polyline a list of points. COCO: Absolute pixels; bbox is [x, y, width, height], measured from the top-left corner.
How do CVAT classes carry over to COCO?
In CVAT: labels and their attributes are defined in the task meta; every shape names its label. In COCO: a categories list with numeric ids; every annotation points to one with its category_id. The class names stay the same on the way through Supervisely, so rename or merge classes in the project before you export.
Can I convert CVAT to COCO in Python?
After the import, the Python SDK downloads the project as Supervisely JSON and writes COCO on your disk. See the SDK export tutorial.