Try for Free
COMPANY
BlogPressAboutCareers
PRICING
CVAT.ai cloudOn-prem deployment
RESOURCES
InstallQuickstartDocumentation
COMMUNITY
DiscordGitterGitHubContribute
CONTACT US
contact@cvat.ai
CVAT.AI: Exporting Annotations from CVAT to YOLOv8 Format on Windows

Data annotation is key to training machine learning models, especially in computer vision. As the CVAT.ai team, we recommend using CVAT for annotation. However, once annotation is done, you'll need to export the data in a suitable format.

One of the most commonly requested formats is YOLOv8. While not directly supported by CVAT, there's a straightforward workaround that allows you to convert data from the COCO format (which CVAT does support) to YOLOv8, a format that supports polygons.

In this article, we’ll show how you can get the annotations needed from CVAT in a few simple steps and then convert them into YOLO8. For this, we’ll use another intermediate format, capable of representing the same annotations - COCO.  

Let’s start with annotation,  for this article we use a fraction of Cats and Dogs dataset  with two classes: cats and dogs, we’ve selected 10 random images.  

For the purpose of this article, we've annotated the dataset with polygons. You can do this manually or use automatic annotation if you're on the paid plan.

After annotation was done, we’ve exported the annotations in COCO format and named the resulting JSON file coco_annotations.json.

The annotations in our JSON file look like this:

To convert annotations from COCO to YOLOv8 format, we'll use the official COCO Dataset Format to YOLO Format tool provided by Ultralytics. 

Follow these steps to achieve the result:

Let's get your COCO annotations organized just right. The snippet below shows the folder structure:

Next up, you're going to create a .py file with the COCO snippet inside. Call it whatever feels right to you; we went with coco_to_yolo.py.

Any text editor will do the trick, but Visual Studio Code is a solid choice. Here's a peek at what your file should look like:

When your file is all set, place it right next to the COCO annotations folder. Your setup should look something like this:

Time to create a virtual environment! Here's how:

Open PowerShell, and head over to your project folder with running cd command:

Once you're in, create a virtual environment by running the following command:

Get that environment going with (you might need to allow scripts in PowerShell):

If the command above for some reason doesn’t work, try the following:

You'll know it's ready when you see (venv) before your command prompt.

Now, let's install Ultralytics. Just type in:

And wait; this part might take a little bit.

All set? Great! Now, just run:

And there you have it—done! Your converted annotations are now neatly organized in the coco_converted folder, located alongside the other files. Please note that the coco_annotations part might have a different name in your case if you named the exported .json file differently.

Inside this folder, you'll find a list of .txt files that have the same names as the images in the dataset.

Each .txt file contains annotations in YOLO8 format.

Now that your data is in the YOLOv8 format, you're ready to use it in your models. This opens up exciting new possibilities and improves your machine learning projects. Keep an eye out for our next articles. We'll go deeper into how to use these converted annotations in your models effectively.


This is just the start of a journey toward more efficient, powerful, and flexible machine learning models.

And that’s it for today. Let us know what you think? 


Happy annotating!

Not a CVAT.ai user?  Click through and sign up here

Do not want to miss updates and news? Have any questions? Join our community:

Facebook

Discord

LinkedIn

Gitter

GitHub

March 28, 2024
CVAT Team
Go Back