This is an interface for SinGAN, designed to enable dynamic image augmentations using the original code. Specifically it avoids saving or loading any type of data (models or images).
The interface is simple: Given a tensor image produce a list of n augmentations of it:
from apps import singan_augment
images_augmented = singan_augment(img_tensor_CHW, n_aug)
In detail:
>>> from PIL import Image
>>> from apps import singan_augment, toimage, totensor
>>> img_path = 'Input/Images/mountains.jpg'
>>> img = Image.open(img_path)
>>> images_augmented = singan_augment(totensor(img), 5)
>>> toimage(images_augmented[0])
The result is a PIL image.
Note that a call to singan_augment
will take a while (20-60min) as it trains a GAN on your image.
Once trained, generating augmentations is very fast. Therefore the number of desired augmentations has a negligible impact on the total run-time.