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
- 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 flip@linkedai.co
Report Issues
Please help us by reporting any issues you may have while using Flip.
License
Metadata
Release files for flip-data 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flip-data-0.2.1.tar.gz | 29.0 kB | Without provenance | Details for flip-data-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flip_data-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for flip_data-0.2.1-py3-none-any.whl |
Total release size: 65.5 kB
Release files / flip-data-0.2.1.tar.gz
| Download URL | flip-data-0.2.1.tar.gz |
|---|---|
| Size | 29.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f5f65b5849f985a79a9a9db504793dfb55f78946ec9df731955ec02da7ff2e29
|
|
BLAKE2b-256 checksum How to use checksums |
cdfb107d9ce75c539631cb741b5e5d19aaeef0adc20bdf4ef55f0242b73bb716
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / flip_data-0.2.1-py3-none-any.whl
| Download URL | flip_data-0.2.1-py3-none-any.whl |
|---|---|
| Size | 36.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de9863e7b9f5b10e8675776adaecfa09ddcbb492587c4c15c58a8a872a47e8a1
|
|
BLAKE2b-256 checksum How to use checksums |
f578a737b7f013e1a3d4f31a21cefaabc50a5d1509f7b31e22e21479e5b5c3b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Security for flip-data 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.