Efficiently Composable Data Augmentation on the GPU with Jax
Project description
Augmax
Augmax is an image data augmentation framework supporting efficiently-composable transformations
with support for JAX function transformations.
Its strengths are efficient execution of complex augmentation pipelines and batched data augmentation on the GPU/TPU via the use of jax.jit
and jax.vmap
.
In existing data augmentation frameworks, each transformation is executed separately, leading to many unnecessary memory reads and writes that could be avoided. In contrast, Augmax tries its best to fuse transformations together, so that these data-intensive operations are be minimized.
Getting Started
Augmax aims to implement an API similar to that of Albumentations. An augmentation pipeline is defined as a sequence of transformations, which are then randomly applied to the input images.
import jax
import augmax
transform = augmax.Chain(
augmax.RandomCrop(256, 256),
augmax.HorizontalFlip(),
augmax.Rotate(),
)
image = ...
rng = jax.random.PRNGKey(27)
transformed_image = transform(rng, image)
Batch-wise Augmentation on the GPU
Leveraging the JAX infrastructure,
it is possible to greatly accelerate data augmentation by using Just-in-Time compilation (jax.jit
),
which can execute the code on the GPU, as well as batched augmentation (jax.vmap
).
Augmenting a single image on the GPU
transformed_image = jax.jit(transform)(rng, image)
Augmenting an entire batch of images on the GPU
sub_rngs = jax.random.split(rng, images.shape[0])
transformed_images = jax.jit(jax.vmap(transform))(sub_rngs, images)
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
File details
Details for the file augmax-0.3.4.tar.gz
.
File metadata
- Download URL: augmax-0.3.4.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a0cd88878db0862c6c170037632aa68e65d6927efeedbb940d69c3499d895fe |
|
MD5 | da66c835db680617ce47c8e19ca83853 |
|
BLAKE2b-256 | d647f98062d15567941f95085b6135da3979314872d7bae220c5903437f17455 |
File details
Details for the file augmax-0.3.4-py3-none-any.whl
.
File metadata
- Download URL: augmax-0.3.4-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec674847451ef135a117ff9a2144facde26af6f7503de82d09f26e1221ec57ab |
|
MD5 | 1fad1abcec296a673c9a92fa13dc2ada |
|
BLAKE2b-256 | d5681a4d5f485e9b7129130645983cd8d86a27d4a1a279a83a55afc40934b728 |