Giter VIP home page Giter VIP logo

annotation-converters's Introduction

Annotation-converters

This Repo covers all formats of annotations for Object Detection and can easily convert from one form to another using attached scripts

All computer vision problems require annotated datasets and for training deep neural networks data needs to be annotated in defined form. For Object Detection, there are many available formats for preparing and annotating your dataset but the most popular and used formats are Pascal VOC and Microsoft COCO.

MS COCO

COCO is large scale images with Common Objects in Context (COCO) for object detection, segmentation, and captioning data set. COCO has 1.5 million object instances for 80 object categories. COCO stores annotations in a JSON file.
COCO Bounding box: (x-top left, y-top left, width, height)

Pascal VOC

Pascal Visual Object Classes(VOC) provides standardized image data sets for object detection. Pascal VOC is an XML file, unlike COCO which has a JSON file.
Pascal VOC Bounding box :(xmin-top left, ymin-top left, xmax-bottom right, ymax-bottom right)

Darknet YOLO

YOLO reads or predicts bounding boxes in different format compared to VOC or COCO.
YOLO Bounding box : (x_center, y_center, width, height) --> all these coordinates are normalized with respect to image width & height.

In Pascal VOC and YOLO we create a file for each of the image in the dataset. In COCO we have one file each, for entire dataset for training, testing and validation.

Usually, when working on custom datasets we end up wasting lot of time in converting annotations from one format to another suitable to object detection models or frameworks. This is really frustrating and I compiled few annotations converter scripts which covers most of the cases and saves you time! You can now focus more on productive tasks such as improving model performance or training more efficiently.

Scripts

  • JSON_to_txt.py

    • It converts MS COCO JSON file to a text file for each image and the format is {class_id, x_min, y_min, width, height}
  • Yolo_to_Voc.py

    • It converts YOLO text files to Pascal VOC format XML files
    • (x_c_n, y_c_n, width_n, height_n) --> (x_min, y_min, x_max, y_max)
  • XML_to_JSON.py && voc2coco.py

    • These python scripts convert all XML files of a dataset into MS COCO readable JSON file.
      python XML_to_JSON.py ./annotations_dir/ ./json_dest_dir/coco_output.json
  • gt_yolo2json.py && pred_yolo2json.py

    • It converts all YOLO text files into MS COCO readable JSON file.
    • For ground truth YOLO text files --> gt_yolo2json.py
    • For YOLO predicted text files --> pred_yolo2json.py
  • cocoGT_to_Yolo.py

    • It converts MS COCO ground truth text files to YOLO format. It also has a function to convert YOLO text files to VOC format. Feel free to change the code and switch between the functions.
  • JSON --> VOC XML files

    • Json2PascalVoc is a Python library for converting some special Json strings to PascalVOC format XML files.
      pip install Json2PascalVoc
    from Json2PascalVoc.Converter import Converter
       
    myConverter = Converter()
    #returns a Converter Object
    myConverter.convertJsonToPascal("data.json")
    #Converts Json to PascalVOC XML and saves the XML file to the related file path
    

annotation-converters's People

Contributors

ngun7 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.