Generate thousands of new 2D images from a small batch of objects and backgrounds.
Project description
Flip
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)
Transformers
The main transformers are:
- Transformer
- Compose
- ApplyToObjects
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.
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.
IO
- SaveImage: Save a .jpg File with the new generated image.
- 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 flip@linkedai.co
Report Issues
Please help us by reporting any issues you may have while using Flip.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for flip_data-0.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1f6234df1c9e5ee7249f1c3b535fb937fde0516cb4bf818c55afeed98cbd869 |
|
MD5 | 9fb97d1881122976cceaa54330dbbeec |
|
BLAKE2b-256 | 63cbe37eff00e48e128311eaaf2d8f286dd0495790967d020c25f31da35d4150 |