Convert COCO
to YOLO
Import COCO, check the labels in the labeling toolbox, export YOLO. YOLO is the format Ultralytics YOLO models train on.
COCO vs YOLO
COCO and YOLO describe the same objects in different files and notations.
| COCO | YOLO | |
|---|---|---|
| Annotation files | One JSON file per dataset (annotations/instances.json) that lists images, annotations and categories. | One TXT file per image in labels/, and a YAML file (data_config.yaml) with the class names and the train and val folders. |
| Coordinates | Absolute pixels; bbox is [x, y, width, height], measured from the top-left corner. | Normalized to 0–1; a box is x_center, y_center, width, height. |
| Shapes | Boxes, polygons or RLE masks, keypoints and image captions. | Boxes for detection, polygons for segmentation, keypoints for pose: one task per label set. |
| Classes | A categories list with numeric ids; every annotation points to one with its category_id. | Each line starts with a zero-based class index; the names are listed in the YAML file. |
What the conversion changes
Between the formats
- COCO pixel boxes ([x, y, width, height] from the corner) become YOLO boxes (centre and size, divided by the image size).
- COCO polygons go to YOLO segmentation as normalized polygons; for YOLO detection they are turned into boxes first.
- COCO category ids are replaced by zero-based indexes in the order of the YAML names list.
Import COCO
- Instances (polygons and boxes) and captions are imported; keypoints go through Import COCO Keypoints.
- Holes in polygons are kept.
- The info and licenses sections and the per-image details of the file are not imported.
Export to YOLO
- For detection the project must hold rectangles only: Convert Class Shape turns polygons and masks into boxes first.
- For segmentation, polygons, bitmaps and alpha masks are exported; for pose, keypoint graphs. Other shapes are skipped.
- The train and val image tags decide the split; untagged images go to train.
Convert COCO to YOLO in three steps
- 01
Import COCO
Upload your COCO folder or archive to Supervisely and run Import COCO from the Ecosystem: it creates a project with the images and labels (COCO import guide).
- 02
Review in the labeling toolbox
Open the project in the image labeling toolbox to check classes and fix labels before they go to YOLO.
- 03
Export to YOLO
Open the menu of the project, choose Download via app and run Convert Supervisely to YOLO v5 format for detection or Export to YOLOv8 format for segmentation and pose. The archive appears in Tasks and Team Files.
Apps in the Supervisely Ecosystem
ImportImport COCOConverts COCO instances and captions to a Supervisely project.Open in Ecosystem
Import · keypointsImport COCO KeypointsConverts COCO keypoints to Supervisely.Open in Ecosystem
Export · detectionConvert Supervisely to YOLO v5 formatWrites the boxes of a project in YOLO v5 format and prepares a tar archive for download.Open in Ecosystem
Export · segmentation and poseExport to YOLOv8 formatWrites a project in YOLOv8 format for segmentation or pose.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 YOLO 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 COCO created
sly.download_fast(api, project_id=12345, dest_dir="sly_project")
# task_type: "detect", "segment" or "pose"
sly.convert.project_to_yolo("sly_project", "yolo", task_type="detect")Frequently asked questions.
Can I convert COCO to YOLO without code?
Yes. Import the data with Import COCO, check it in the image labeling toolbox, then export it with Convert Supervisely to YOLO v5 format or Export to YOLOv8 format. Both start from the Supervisely web interface.
What changes when COCO becomes YOLO?
COCO pixel boxes ([x, y, width, height] from the corner) become YOLO boxes (centre and size, divided by the image size). COCO polygons go to YOLO segmentation as normalized polygons; for YOLO detection they are turned into boxes first. COCO category ids are replaced by zero-based indexes in the order of the YAML names list.
Does YOLO use the same coordinates as COCO?
No. COCO uses absolute pixel coordinates, YOLO coordinates divided by the image size. COCO: Absolute pixels; bbox is [x, y, width, height], measured from the top-left corner. YOLO: Normalized to 0–1; a box is x_center, y_center, width, height. The export does the conversion.
How do COCO classes carry over to YOLO?
In COCO: a categories list with numeric ids; every annotation points to one with its category_id. In YOLO: each line starts with a zero-based class index; the names are listed in the YAML file. 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 COCO to YOLO in Python?
After the import, the Python SDK downloads the project as Supervisely JSON and writes YOLO on your disk. See the SDK export tutorial.