When you use Yolo-model, you might create annotation labels with Yolo-mark.
For example,
obj.names
- example of list with object namestrain.txt
- example with list of image filenames for training Yolo modeltrain/
- 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! ๐ฅ
- 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
Just clone this repository.
git clone https://github.com/Taeyoung96/Yolo-to-COCO-format-converter.git
cd Yolo-to-COCO-format-converter
When you have your own Yolo annotation format, just change a little bit!
In main.py
, there is a code that declare the classes. You will change this with your obj.names
.
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).
You need to provide 2 argments(essential) & 1 argments(optional).
- path : Absolute path of train.txt
- output : Name of the json file
- debug : If you want to check the bounding boxes or annotation information.
When you want to make json file,
python main.py --path [Absolute Path of train.txt] --output [Name of the json file]
- (For example)
python main.py --path /home/taeyoungkim/Desktop/Yolo-to-COCO-format-converter/tutorial/train.txt --output train
Or when you want to check the bounding boxes,
python main.py --path [Absolute Path of train.txt] --output [Name of the json file] --debug
- (For example)
python main.py --path /home/taeyoungkim/Desktop/Yolo-to-COCO-format-converter/tutorial/train.txt --output train --debug
If you want to read json files more clearly, you should use JQ
!
- JQ Manual
- (For example)
cd output
jq . train.json > train_jq.json
Result of Json file
On debug mode, you can check bounding boxes
On debug mode, you can check annotation information on terminal
- I created a repository by referring to chrise96/image-to-coco-json-converter.
- GeeJae Lee helped to make it.