Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Yolo to COCO annotation format converter
| Date | Stars |
|---|---|
| 2026-07-24 | 306 |
| 2026-07-25 | 306 |
| 2026-07-28 | 306 |
| 2026-07-30 | 304 |
| 2026-08-06 | 304 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# Yolo-to-COCO-format-converter
When you use **Yolo-model**, you might create annotation labels with [Yolo-mark](https://github.com/AlexeyAB/Yolo_mark).
For example,
- `obj.names` - example of list with object names
- `train.txt` - example with list of image filenames for training Yolo model
- `train/` - example of folder that contain images and labels
> - *.jpg : example of list of image
> - *.txt : example of list of label
**But, when you want to use another model(ex. efficientdet), you need another annotation format! :disappointed_relieved:**
### This code will help you make a COCO format annotations with Yolo format!
### Updates
- Oct 13th, 2021 - We could support not only **`Yolo-mark`** outputs, but also **`OpenLabeling`** outputs!
Also, We could make segmentation mask polygons information in json file.
Thanks to [@NauchtanRobotics](https://github.com/NauchtanRobotics)!
## How to use
### Requirements
- numpy
- OpenCV
You can make same environment with anaconda environment.
- `conda create -n Yolo-to-COCO python=3.8`
- `conda activate Yolo-to-COCO`
- `pip install numpy`
- `pip install opencv-python`
- `pip install imagesize`
Just clone this repository.
- `git clone https://github.com/Taeyoung96/Yolo-to-COCO-format-converter.git`
- `cd Yolo-to-COCO-format-converter`
### It will be easy to understand if you refer to the tutorial folder.
When you have your own Yolo annotation format, just change a little bit!
### 1. Change `classes` with your own dataset.
In `main.py`, there is a code that declare the classes. You will change this with your `obj.names`.
<p align="center"><img src="https://user-images.githubusercontent.com/41863759/100314803-cfd36800-2ffa-11eb-90ed-bf821ba2de4f.png" width="400px"></p>
Next, follow step 2 if you have your annotations in separate text files, one for each image.
Alternatively, follow step 3 if you wish to work from YOLO annotations which are concatenated
into a single file.
### 2. Prepare COCO annotation file from multiple YOLO annotation files.
#### 2a. Image and annotation files are side by side (Yolo-mark output: Seems like tutorial folder)
Use this approach if your training data file structure looks like this:
<pre>
dataset_root_dir/
Photo_00001.jpg
Photo_00001.txt
Photo_00002.jpg
Photo_00003.txt
</pre>
You don't need to specify `yolo-subdir` argument.
- `python main.py --path <Absolute path to dataset_root_dir> --output <Name of the json file>`
- (For example)`python main.py --path /home/taeyoungkim/Desktop/Yolo-to-COCO-format-converter/tutorial/ --output train`
#### 2b. Annotations are nested in a folder 'YOLO_darknet' (OpenLabeling output)
Use this approach if your annotations are in nested a level below the image files like this:
<pre>
dataset_root_dir/
YOLO_darknet/
Photo_00001.txt
Photo_00002.txt
Photo_00001.jpg
Photo_00002.jpg
</pre>
Command to use:
- `python main.py --yolo-subdir --path <Absolute path to dataset_root_dir> --output <Name of the json file>`
- `python main.py --yolo-subdir --box2seg --path <Absolute path to dataset_root_dir> --output <Name of the json file>`
---
The arg `--box2seg` initializes segmentation mask polygons that have box shapes.
This is useful for when changing your modeling from object detection to image segmentation.
These masks can then be reshaped using software such as the interface provided by makesense.ai
### 3. Prepare COCO annotation file from a single YOLO annotation file
#### 3a. Check the absolute path in `train.txt`.
Make sure that it points to the absolute path to the folder where the image and text files are located.
You can easily change the path with `Text Editor`(Ubuntu 18.04) or `NotePad` (Window 10).
<p align="center"><img src="https://user-images.githubusercontent.com/41863759/100314808-d366ef00-2ffa-11eb-96fe-f4a2d5ffExcerpt of 7,842 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:d3e6d4c0f2a18a63, topic:yolo, readme:object detection, readme:image segmentation