Giter Site home page Giter Site logo

createml_annotations_json's Introduction

Generate Annotations JSON Format for CreateML with Python

Python script which generates annotations in JSON format required for training object detection models using CreateML.

CreateML requires a list of dictionaries with information about the selected bounding boxes: center and size (height and width) of the bounding box.

annotations

Code Description

The following code shows how to draw bounding boxes using matplotlib library. It iterates over the images of a folder and draws bounding boxes to get the center coodinates, heitgh and width of the bounding box.

Detailed description on: https://medium.com/@eriksols/generate-annotations-json-format-for-createml-apple-with-python-90fc848cd439?postPublishedType=repub

Run Script

Pass the path to the images folder (image_folder = 'path_to_image_folder'). Each image must be named with the corresponding class in order to detect the label, example: 'dog_01.jpg'.

folder_exm

Run generate_json.py script

Code will iterate over all the images contained on the images folder.

Now, you must draw the bounding box over the interest object. Once you are confident about the drawn bounding box, press "q" to generate and store the corresponding dictionary and continue the process with the next image.

bb

A list containing the dictionaries of all images will be generated.

dict

Finally a JSON file will be generated.

json_file

Open and Iterate JSON file

Run open_json_file.py

This script opens and iterates over the list containing the image dictionaries. This script also shows how to access the the list elements and the corresponding dictionaries.

It prints: List length (number of contained dictionaries) Image dictionary Label dictionary Coordinates dictionary

res

That's all! :D

createml_annotations_json's People

Contributors

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