imgaug-tf
An image augmentation library for tensorflow. This library is implemented in TF native and has been tested to work with TPU.
Installation
!pip install -U git+https://github.com/hirune924/imgaug-tf
Required packages:
- tensorflow (2.6.3 or higher recommended)
- tensorflow_addons (0.14.0 or higher recommended)
- tensorflow_probability (0.14.1 or higher recommended)
Quick Start
imgaugtf is implemented to work simply with tf.data. Example of use single transform.
import imgaugtf
image = imgaugtf.random_solarize_add(image, addition=30, prob=0.5)
You can also apply transform for a mask as same as a image.
import imgaugtf
image = imgaugtf.seg.random_solarize_add(image, mask, addition=30, prob=0.5)
You can also randomly select n of multiple transformations to apply, as shown below. You can use mixup or cutmix on batched images.
import imgaugtf
def augmentation(example):
example['image'] = imgaugtf.random_resized_crop(example['image'], size=[256, 256], prob=1.0)
example['image'] = imgaugtf.apply_n(example['image'], functions=imgaugtf.OPERATORS, num_ops=2, prob=1.0)
return example
def batch_augmentation(example, num_class=120):
image = example['image']
label = tf.one_hot(example['label'], num_class)
image, label = imgaugtf.cutmix(image, label)
return image, label
result = next(iter(dataset.map(augmentation).batch(15).map(batch_augmentation)))
for i in range(10):
plt.imshow(result[0][i])
plt.show()
functions is list of dict like this example. dict has keys of 'func' and 'option'. you can customize it you like.
[
{"func": imgaugtf.random_cutout, "option": {"num_holes": 8, "hole_size": 20, "replace": 0}},
{"func": imgaugtf.random_solarize, "option": {"threshold": 128}},
{"func": imgaugtf.random_solarize_add, "option": {"addition": 30, "threshold": 128}},
]
Augmentations
pixel
| image | mask | |
|---|---|---|
| original | ||
| random_solarize | ||
| random_solarize_add | ||
| random_color | ||
| random_contrast | ||
| random_brightness | ||
| random_posterize | ||
| random_invert | ||
| random_equalize | ||
| random_sharpness | ||
| random_autocontrast | ||
| random_hsv_in_yiq | ||
| random_gaussian_filter2d | ||
| random_mean_filter2d | ||
| random_median_filter2d | ||
| random_cutout | ||
| random_gray | ||
| random_hue | ||
| random_saturation | ||
| random_gamma | ||
| random_jpeg_quality | ||
| random_gaussian_noise | ||
| random_speckle_noise |
geometory
| image | mask | |
|---|---|---|
| original | ||
| random_flip_left_right | ||
| random_flip_up_down | ||
| random_resized_crop | ||
| random_rotate | ||
| random_translate_x | ||
| random_translate_y | ||
| random_shear_x | ||
| random_shear_y | ||
| random_zoom | ||
| random_grid_shuffle | ||
| random_affine | ||
| random_elastic_deform | ||
| random_sparse_warp | ||
| random_crop |
blend
- mixup
- cutmix
compose
- apply_one
- apply_n
Metadata
Release files for imgaugtf 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| imgaugtf-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / imgaugtf-1.0.0-py3-none-any.whl
| Download URL | imgaugtf-1.0.0-py3-none-any.whl |
|---|---|
| Size | 24.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43033dc79289787bc321f2fd02ac33132226a95a351b5779c0e75f0150a811b5
|
|
BLAKE2b-256 checksum How to use checksums |
4db8d1af4be32554f8171a73d3b1a8c626029f1a463e2dd27278dccbef4ee794
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9
|
Security for imgaugtf 1.0.0
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.