• Stars
    star
    196
  • Rank 192,449 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 3 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Yolo to COCO annotation format converter

Yolo-to-COCO-format-converter

When you use Yolo-model, you might create annotation labels with 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! ๐Ÿ˜ฅ

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!

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
  • 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.

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:

    dataset_root_dir/
        Photo_00001.jpg
        Photo_00001.txt
        Photo_00002.jpg
        Photo_00003.txt

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:

    dataset_root_dir/
        YOLO_darknet/
            Photo_00001.txt
            Photo_00002.txt
        Photo_00001.jpg
        Photo_00002.jpg

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).

3.1 How To Use path_replacer.py

If you want to quickly create a train.txt file in Ubuntu, you can use path_replacer.py.

Works with 2 simple arguments.

  • path_image_folder: File path where the images are located.
  • path_txt: File path of the 'txt' file you want to create.

When you want to use

  • python path_replacer.py --path_image_folder <File path where the images are located> --path_txt <File path of the 'txt' file you want to create>
  • (For example)python path_replacer.py --path_image_folder /home/taeyoungkim/Desktop/Yolo-to-COCO-format-converter/tutorial/train --path_txt /home/taeyoungkim/Desktop/Yolo-to-COCO-format-converter/tutorial/train.txt

3.2 Now run the code.

You need to provide 2 argments(essential) & 3 argments(optional).
essential

  • path : Absolute path of train.txt
  • output : Name of the json file

optional

  • yolo-subdir : If your annotation label have OpenLabeling output.
  • box2seg : If you want to make segmentation mask polygons that have box shapes.
  • 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

Tips

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

Results

Result of Json file

On debug mode, you can check bounding boxes

On debug mode, you can check annotation information on terminal

Contributors

License

Copyright (c) 2021 Tae Young Kim

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

More Repositories

1

ICRA-2022-SLAM-paper-list

Unofficial ICRA 2022 SLAM paper list
287
star
2

Awesome-LiDAR-IMU-calibration

๐Ÿ˜Ž A current list of LiDAR-IMU calibration method
125
star
3

IROS-2022-SLAM-paper-list

Unofficial IROS 2022 SLAM paper list
47
star
4

SLAM-Resources-for-Beginner

Highly recommended resources for SLAM newbies (Lecture, Reviewed paper, Books, Tutorial, etc)
23
star
5

Algorithm-study

์กฐ๊ธˆ์”ฉ ๊พธ์ค€ํ•˜๊ฒŒ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ๋ฅผ ํ’€๋ ค๊ณ  ๋…ธ๋ ฅ์ค‘์ž…๋‹ˆ๋‹ค.
Jupyter Notebook
22
star
6

SLAM-backend-tutorial

My personal solution for "AirLab Summer School Session 2.2"
C++
17
star
7

Depth-estimation-with-ORB-SLAM2

20๋…„๋„ ํ›„๋ฐ˜๊ธฐ Toy Project 'Depth estimation with ORB-SLAM2'์— ๋Œ€ํ•œ ์†Œ์Šค์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.
C++
14
star
8

Taeyoung96.github.io

'Taeyoung96'์˜ ๊ฐœ๋ฐœ ๋ธ”๋กœ๊ทธ ์ž…๋‹ˆ๋‹ค. :)
SCSS
13
star
9

2021-Capstone-Design

2021-Spring-Capstone-Design '์ „๊ธฐ์ฐจ ๋ฌด์„  ์ถฉ์ „ ๋กœ๋ด‡'
C
11
star
10

hdl_localization_tutorial

Step-by-step tutorial to facilitate hdl localization package with docker! ๐Ÿณ
Dockerfile
10
star
11

Rotation-operator-toy-example

Implementation of Rotation operator (SO(3)) without Library
Python
10
star
12

ORB_SLAM3_detailed_comments_KOR

The easiest way to understand ORB_SLAM3 in Korean
C++
9
star
13

OctoMap-ROS2

[ROS2 humble] Convert 3D LiDAR map to 2D Occupancy Grid Map
C++
9
star
14

Make-ORB-SLAM2-RGBD-dataset

Make Custom ORB_SLAM2 RGB-D dataset with real sense camera
Python
9
star
15

VINS-MONO-studying

I personally studied VINS-MONO and commented in Korean.
C++
8
star
16

TaeyoungKim_CV

7
star
17

Robotics-Summary

๋กœ๋ด‡ํ•™๋ถ€ ์ „๊ณต ๊ณผ๋ชฉ ์š”์•ฝ์ง‘๐Ÿ“š
5
star
18

Trobleshooting-Note

์‚ฝ์งˆ, ๊ตฌ๊ธ€๋ง์˜ ๊ฒฐ๊ณผ๋ฅผ ๊ธฐ๋กํ•˜๊ธฐ ์œ„ํ•œ Repsitory
5
star
19

GTSAM-example-supplementary

A personal study material for the IMU Factor example in Korean
Python
5
star
20

BARAM_readme

๋ฐ”๋žŒ ํ”„๋กœ์ ํŠธ์šฉ README.md ํŒŒ์ผ ์ž…๋‹ˆ๋‹ค.
5
star
21

ROS2-Docker-tutorial

ROS2 Docker tutorial with VSCode
Python
5
star
22

Pytorch-tutorial

I got a Pytorch tutorial and summarize it. :)
Jupyter Notebook
5
star
23

Runner-alarm-system

20๋…„๋„ ์ „๋ฐ˜๊ธฐ Toy Project '๋”ฅ๋Ÿฌ๋‹ ๊ธฐ๋ฐ˜ ๋Ÿฌ๋„ˆ ์•Œ๋žŒ ์‹œ์Šคํ…œ'์— ๋Œ€ํ•œ ์†Œ์Šค์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.
Python
5
star
24

Visual-odometry-tutorial

Tutorial code for "AirLab Summer School Session 2.1"
Python
4
star
25

Maze-Game-Project

19๋…„๋„ ํ›„๋ฐ˜๊ธฐ Toy Project 'Upgrade Miro Game'์— ๋Œ€ํ•œ ์†Œ์Šค์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.
C++
4
star
26

SLAM-dockerfile-cheatsheet

Dockerfile recipe for SLAM algorithm
3
star
27

Solving-ubuntu-frontend-lock

Shell file for solving Ubuntu frontend lock error.
Shell
3
star
28

Histogram_Matching_Qt

Histogram specification (Equalization) implementation
C++
3
star
29

EM-method-for-Laser-beam-model

Implementation "learn intrinsic parameter" pseudocode in Probabilistic robotics (Chapter 6.3.2)
Python
3
star
30

VINS-Mono-docker-tutorial

Simple tutorial for VINS-Mono docker (w/ Open LORIS-Scene dataset)
3
star
31

ORB-SLAM2-with-saved-point-cloud

Execute ORB-SLAM2 system and save global point cloud map
C++
3
star
32

Deep-learning-from-scratch

ใ€Ž๋ฐ‘๋ฐ”๋‹ฅ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋Š” ๋”ฅ๋Ÿฌ๋‹ใ€(ํ•œ๋น›๋ฏธ๋””์–ด, 2017)์˜ ์ฑ…์„ ๋ณด๊ณ  ์†Œ์Šค์ฝ”๋“œ๋ฅผ ๋ณด๊ณ  ๊ณต๋ถ€๋ฅผ ํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค.
Python
3
star
33

f1tenth-my-own-driver

Midterm project for 2021 Fall Robot Navigation
Python
2
star
34

RobotExperiment4-TermProject

Term project for 2021 Fall Robot Experiment 4
C
2
star
35

Panoramic_Image_Stitching

C++
2
star
36

Taeyoung96

2
star
37

RealSense-Example

Example of real sense libraries
Python
2
star
38

cpp_project

C++
2
star
39

Image-Min-Max-Normalization

Python
2
star
40

2021-Spring-Computer-Vision

Assignment for 2021 spring Computer Vision lecture
C++
2
star
41

Image_Viewer_Qt

Qt๋ฅผ ์ด์šฉํ•˜์—ฌ Raw data Image๋ฅผ ๋„์šฐ๋Š” ํ”„๋กœ๊ทธ๋žจ์ž…๋‹ˆ๋‹ค.
C++
2
star
42

2021-Spring-Deep-Learning

Assignment for 2021 spring Deep Learning lecture
Jupyter Notebook
2
star
43

Make-BTS-Custom-Dataset

Python
2
star
44

librealsense-Docker

Unoffical Intel RealSense SDK docker image
Dockerfile
2
star
45

Resnet-from-scratch

Implementation of Resnet from scratch with Pytorch
Jupyter Notebook
1
star
46

LIO-SAM-save-trajectory

LIO-SAM added trajectory save function to directly utilize evo tool
C++
1
star
47

Multi-turtlebot3-Gazebo-ROS2

[ROS2 humble] Custom gazebo package
C++
1
star
48

RobotControl-TermProject

Term project for 2021 Fall Robot Control
MATLAB
1
star