All Projects → Taeyoung96 → Yolo-to-COCO-format-converter

Taeyoung96 / Yolo-to-COCO-format-converter

Licence: MIT license
Yolo to COCO annotation format converter

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Yolo-to-COCO-format-converter

JSON2YOLO
Convert JSON annotations into YOLO format.
Stars: ✭ 222 (+26.14%)
Mutual labels:  yolo, coco
Cocostuff10k
The official homepage of the (outdated) COCO-Stuff 10K dataset.
Stars: ✭ 248 (+40.91%)
Mutual labels:  annotations, coco
datumaro
Dataset Management Framework, a Python library and a CLI tool to build, analyze and manage Computer Vision datasets.
Stars: ✭ 274 (+55.68%)
Mutual labels:  yolo, coco
Myvision
Computer vision based ML training data generation tool 🚀
Stars: ✭ 453 (+157.39%)
Mutual labels:  yolo, coco
Yolo person detect
person detect based on yolov3 with several Python scripts
Stars: ✭ 212 (+20.45%)
Mutual labels:  yolo, coco
Rectlabel Support
RectLabel - An image annotation tool to label images for bounding box object detection and segmentation.
Stars: ✭ 338 (+92.05%)
Mutual labels:  annotations, yolo
etiketai
Etiketai is an online tool designed to label images, useful for training AI models
Stars: ✭ 63 (-64.2%)
Mutual labels:  annotations, yolo
Label Studio
Label Studio is a multi-type data labeling and annotation tool with standardized output format
Stars: ✭ 7,264 (+4027.27%)
Mutual labels:  annotations, yolo
Oksharedprefs
通过注解生成SharedPreferences包装类,解决跨进程数据访问不同步的问题。
Stars: ✭ 183 (+3.98%)
Mutual labels:  annotations
React Tater
A React component to add annotations to any element on a page 🥔
Stars: ✭ 235 (+33.52%)
Mutual labels:  annotations
Placeholderview
This library provides advance views for lists and stacks. Some of the views are build on top of RecyclerView and others are written in their own. Annotations are compiled by annotation processor to generate bind classes. DOCS -->
Stars: ✭ 2,104 (+1095.45%)
Mutual labels:  annotations
Qmbform
Create simple Android forms
Stars: ✭ 184 (+4.55%)
Mutual labels:  annotations
Jsoup Annotations
Jsoup Annotations POJO
Stars: ✭ 242 (+37.5%)
Mutual labels:  annotations
Drf Typed Views
Use type annotations to validate/deserialize request parameters in Dango REST Framework.
Stars: ✭ 181 (+2.84%)
Mutual labels:  annotations
Scan2cad
[CVPR'19] Dataset and code used in the research project Scan2CAD: Learning CAD Model Alignment in RGB-D Scans
Stars: ✭ 249 (+41.48%)
Mutual labels:  annotations
Ray.di
Guice style dependency injection framework for PHP
Stars: ✭ 175 (-0.57%)
Mutual labels:  annotations
Koro1fileheader
VSCode插件:自动生成,自动更新VSCode文件头部注释, 自动生成函数注释并支持提取函数参数,支持所有主流语言,文档齐全,使用简单,配置灵活方便,持续维护多年。
Stars: ✭ 3,137 (+1682.39%)
Mutual labels:  annotations
Sequelize Typescript
Decorators and some other features for sequelize
Stars: ✭ 2,200 (+1150%)
Mutual labels:  annotations
Awesome Data Annotation
A list of tools for annotating data, managing annotations, etc.
Stars: ✭ 204 (+15.91%)
Mutual labels:  annotations
Labelimg
🖍️ LabelImg is a graphical image annotation tool and label object bounding boxes in images
Stars: ✭ 16,088 (+9040.91%)
Mutual labels:  annotations

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].