GithubHelp home page GithubHelp logo

davide710 / augment-it Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 1.85 MB

Twice the dataset, same the time for annotation!

Python 100.00%
computer-vision datalabeling linear-algebra machine-learning math object-detection opencv python yolo dataannotations

augment-it's Introduction

augment-it

Twice the dataset, same the time for annotation!

Multiply the size of the dataset (rotations, changes in brightness and contrast) in no time and don't waste another instant annotating it.

Why?

Data augmentation is fundamental for a good object detection model. The problem is, the most boring part of object detection is annotating the dataset (e.g. using https://pypi.org/project/labelImg/ for YOLO model), and having to do it multiple times because for slightly different images feels like something that should be done automatically. And so it is (from now on)!

How?

Put your annotated images in a directory with the annotation (.txt) files. The code assumes that for the image "my_image.jpg" there is the file "my_image.txt", structured as follows: class_id center_x center_y bounding_box_width bounding_box_height (see examples in resources/), where center_x and bounding_bow_width are normalized to the image width and center_y, bounding_box_height to the image height. Now:

git clone https://github.com/davide710/augment-it.git
cd augment-it
pip install numpy opencv-contrib-python

You can see a demo of how the code works by running python3 demo.py. This shows how the images (data I used for an actual object detection model) are rotated and how the bounding box automatically follows the object thanks to the magic of linear algebra.

original image rotated image and box

To use the functions in your code, simply

from rotation import rotate
from brightness_contrast import change_brightness_contrast

rotate(file_list, min_angle=5, max_angle=355, make_annotations=True, rotate_bbox=False, debug=False)
change_brightness_contrast(file_list, min_alpha=0.5, max_alpha=1.5, min_beta=-60, max_beta=60, make_annotations=True)
  • use rotate_bbox=False if your objects are circular (hence you just need to rotate the center)
  • use make_annotations=False if you just want the new images but not the new annotation files
  • rotate will save the output files in the directory "rotated/" and add "_rot" to all file names
  • change_brightness_contrast will save the output files in the directory "br_and_con/" and add "_bc" to all file names

Leave the boring stuff to the machines

augment-it's People

Contributors

davide710 avatar

Stargazers

 avatar

Watchers

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