Image augmentation library for Jax
Project description
imax
Image augmentation library for Jax.
Installation
pip install imax
Usage
from jax import random
import jax.numpy as jnp
from PIL import Image
from matplotlib import pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
from imax import transforms, color_transforms, randaugment
# Setup
random_key = random.PRNGKey(32)
random_key, split_key = random.split(random_key)
image = jnp.asarray(Image.open('./test.jpeg').convert('RGBA')).astype('uint8')
# Geometric transforms:
transform = transforms.rotate(rad=0.7) # create transformation matrix
transformed_image = transforms.apply_transform(image, # apply transformation
transform,
mask_value=jnp.array([0, 0, 0, 255]))
# multiple transformations can be combined through matrix multiplication
# this makes multiple sequential transforms much faster
multi_transform = transform @ transform @ transform
multi_transformed_image = transforms.apply_transform(image,
multi_transform,
mask_value=-1)
# Color transforms:
adjusted_image = color_transforms.posterize(image, bits=2)
# Randaugment:
randomized_image = randaugment.distort_image_with_randaugment(
image,
num_layers=3, # number of random augmentations in sequence
magnitude=10, # magnitude of random augmentations
random_key=split_key
)
# Show results:
results = [transformed_image, multi_transformed_image, adjusted_image, randomized_image]
fig = plt.figure(figsize=(10., 10.))
grid = ImageGrid(fig, 111,
nrows_ncols=(2, 2),
axes_pad=0.1)
for ax, im in zip(grid, results):
ax.axis('off')
ax.imshow(im)
plt.show()
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
imax-0.0.1b11.tar.gz
(20.2 kB
view details)
Built Distribution
imax-0.0.1b11-py3-none-any.whl
(20.6 kB
view details)
File details
Details for the file imax-0.0.1b11.tar.gz
.
File metadata
- Download URL: imax-0.0.1b11.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f31d9b00825dbde36fab254bf78e525c8c4bc0ab022d1d8769202216bdbfc67 |
|
MD5 | 291ee63b58ea1638562939cece707500 |
|
BLAKE2b-256 | a14e64945ab4f06ab870a3dbb94a3259428eafd1d502c767dc5b6d5598a54169 |
File details
Details for the file imax-0.0.1b11-py3-none-any.whl
.
File metadata
- Download URL: imax-0.0.1b11-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e791215523e269d985770d0500e35c3bd5fd4cad06b3474b29988df4485b62ac |
|
MD5 | 28e626532b0cfbff8a50cddf31af655a |
|
BLAKE2b-256 | dc7bd6608631d87a9e9aad54c9eb9dcb8c66a9f540213a5cc38934736720b1bb |