Skip to main content

Efficiently Composable Data Augmentation on the GPU with Jax

Project description

Augmax

PyPI version Documentation Status

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

augmax-0.3.1.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

augmax-0.3.1-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file augmax-0.3.1.tar.gz.

File metadata

  • Download URL: augmax-0.3.1.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for augmax-0.3.1.tar.gz
Algorithm Hash digest
SHA256 55dd6029e1cf89b8e5351fdf883d7fc8d0e2479a5ade805ddbb86f0ff06dcea2
MD5 19631c986afc0775e9cb34261811b8be
BLAKE2b-256 f3562ac82daf0029387245a31ab6327e4da2340b8e87b387dbf45a62c00f6286

See more details on using hashes here.

File details

Details for the file augmax-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: augmax-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for augmax-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7b32fefdf4d0a06c0bf0828bdbf8d7ad408a70249aa81d8b68875692f976a5a5
MD5 917c96b44b7195a6fc3339010e9d8b30
BLAKE2b-256 7c9a2724b4afc7026f27bbab7b65496eb1a39a89c3669efde78677183a5f5c03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page