A library, based on PyTorch, that performs data augmentation on the GPU
Project description
GPU accelerated data augmentation
This code is an extension on the imgaug package that provides flexible use of data augmentation. In particular, we provide standard augmentation strategies on the GPU, as some of these can be intensive on the CPU. Our GPU translation is based on PyTorch. The current version supports both 2D and 3D data augmentation, however the 3D augmentation is still in test phase.
Installation
Install the dependencies and you are ready to go!
pip install -r requirements.txt
Usage
Import the required modules:
import imageio
import torch
from augmentation_2d import FlipX, FlipY, Rotate90, AddNoise, RandomDeformation
Read an image into a tensor and transfer it to the GPU:
x = imageio.imread('img/elaine.png').astype('float')
shape = x.shape
x = torch.Tensor(x).unsqueeze(0).unsqueeze(0).cuda()
Flip the image along the x and y-axis:
flipx = FlipX(shape)
y = flipx(x)
flipy = FlipY(shape)
y = flipy(x)
Rotate the image 90 degrees:
rotate = Rotate90(shape)
y = rotate(x)
Rotate the image randomly:
rotate = RotateRandom(shape)
y = rotate(x)
Add noise to the image:
noise = AddNoise(sigma_min=20, sigma_max=20)
y = noise(x)
Apply random deformations to the image:
deform = RandomDeformation(shape, sigma=0.01)
y = deform(x)
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
Built Distribution
Hashes for augmentation-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 286df0bd13d2bfa372bd3c49461d78e07111d9967dcbd29c80bc4aa0a330df2f |
|
MD5 | 2a7c9a7d88922675bf1ef4a4f1636fb6 |
|
BLAKE2b-256 | e5387bfbb5a5aab84a7231542268a83be794cd3fa135fc9f61037336e336cc54 |