Giter Site home page Giter Site logo

linkedai / flip Goto Github PK

View Code? Open in Web Editor NEW
301.0 9.0 35.0 82.01 MB

Synthetic Image generation with Flip. Generate thousands of new 2D images from a small batch of objects and backgrounds.

License: GNU General Public License v3.0

Python 100.00%
synthetic-data generated-labels computer-vision object-detection deep-learning hacktoberfest

flip's Introduction

Flip

Python supported

Synthetic Data generation with Flip! Generate thousands of new 2D images from a small batch of objects and backgrounds.

Installation

Install Flip using pip:

pip install flip-data

Dependencies

Flip requires:

  • Python (>= 3.7)
  • Opencv (>= 4.3.0)
  • Numpy (>= 1.19.1)

Quick Start (Example)

To try Flip library you can run examples/data_generator.py. You will need to add background images and objects to compose your new training dataset, then place them in the following directories:

BACKGROUNDS_PATTERN = "examples/data/backgrounds/*"
OBJECTS_PATTERN = "examples/data/objects/**/*"

The main workflow in Flip is to create transformers and then execute them as follows:

## Import Flip transformers
import flip.transformers as tr

OUT_DIR = "examples/result"

...

## Create Child transformers
transform_objects = [
        tr.data_augmentation.Rotate(mode='random'),
        tr.data_augmentation.Flip(mode='y'),
        tr.data_augmentation.RandomResize(
            mode='symmetric_w',
            relation='parent',
            w_percentage_min=0.2,
            w_percentage_max=0.5
        )
    ]

## Create main transformer
transform = tr.Compose([
    tr.ApplyToObjects(transform_objects),
    tr.domain_randomization.ObjectsRandomPosition(
        x_min=0, y_min=0.4, x_max=0.7, y_max=0.7, mode='percentage'
    ),
    tr.data_augmentation.Flip('x'),
    tr.domain_randomization.Draw(),
    tr.labeler.CreateBoundingBoxes(),
    tr.io.CreateJson(out_dir=OUT_DIR, name='img_generate.jpg'),
    tr.io.CreateJson(out_dir=OUT_DIR, name='json_generated.jpg')
])

## Execute transformations
el = tr.Element(image=..., objects=...)
[el] = transform(el)

Object

Transformers

The main transformers are:

  • Transformer
  • Compose
  • ApplyToObjects
  • ApplyToBackground
  • ApplyToCreatedImage

By the way, all Transformers will be executed over objects of class Element and will return a new transformed Element.

Data Augmentation

  • Flip: Flip the Element in x or y axis.
  • RandomResize: Change the size of an Element randomly.
  • Rotate: Rotate Element randomly.
  • Color: Change color space or the element color.
  • Brightness: Changes the brightness in the image.
  • Contrast: Changes the contrast in the image.
  • Saturation: Changes the saturation in the image.
  • Noise: Add noise to the element image.
  • CutOut: Remove a section of the element in the desired area.
  • RandomCrop: Cut the image randomly.

Random Domain

  • Draw: Draw objects over background Element to merge them into a new image.
  • ObjectsRandomPosition: Set Random positions to objects over background Element.

Labeler

  • CreateBoundingBoxes: Draw bounding boxes around the objects contained by a background Element.
  • CreateMasks: Creates the segmentation mask for the objects contained in a background element.

IO

  • SaveImage: Save a .jpg File with the new generated image.
  • SaveMask: Save a .jpg File with the new generated mask.
  • Json: Save generated Labels as a Json.
  • Csv: Save generated Labels as a CSV.

Want to Contribute or have any doubts or feedback?

If you want extra info, email me at [email protected]

Report Issues

Please help us by reporting any issues you may have while using Flip.

License

flip's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flip's Issues

Please consider using a permissive license?

Thanks for the free code!

I would like to use this to generate toy data for unit tests in a CICD setting for closed source software to replace. Butterflies would be more pleasant to look at than the colored blobs we currently generate :) This library's code wouldn't be shipped outside our organization, so I believe that's permitted copyright-wise, but the GPL still makes me nervous; I could see myself screwing up some setting in our deployment logic, or someone other than me might decide the test suite should run at a customer after all.

Assuming you still own all the code, any chance you'd consider switching to a permissive license (Apache, BSD, MIT, whatever)?

Autocreate the required folders

When pip installing or on the first run, should create the required folders

BACKGROUNDS_PATTERN = "examples/data/backgrounds/*"
OBJECTS_PATTERN = "examples/data/objects/**/*"

Background mask

I'd like to ask a question.
Whether it is possible to use a mask on the background so that elements only appear and are drawn within a defined area.

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.