Composite Augmentation Types

class tormentor.AugmentationCascade[source]

Select randomly among many augmentations.

_static/example_images/AugmentationCascade.png

Cascade of perspective augmentation followed by plasma-brightness

augmentation_factory = tormentor.RandomPerspective | tormentor.RandomPlasmaBrightness

A more complete usage of AugmentationCascade and AugmentationChoice can be seen in the following listing which produces the following computation graph. In the graph AugmentationCascade can be though of as all arrows that don’t leave an AugmentationChoice

from tormentor import RandomColorJitter, RandomFlip, RandomWrap, \
    RandomPlasmaBrightness, RandomPerspective, \
    RandomGaussianAdditiveNoise, RandomRotate

linear_aug = (RandomFlip ^ RandomPerspective ^ RandomRotate)  | RandomColorJitter
nonlinear_aug = RandomWrap | RandomPlasmaBrightness
final_augmentation = (linear_aug ^ nonlinear_aug) | RandomGaussianAdditiveNoise

epochs, batch_size, n_points, width, height = 10, 5, 20, 320, 240

for _ in range(epochs):
    image_batch = torch.rand(batch_size, 3, height, width)
    segmentation_batch = torch.rand(batch_size, 1, height, width).round()
    augmentation = final_augmentation()
    augmented_images = augmentation(image_batch)
    augmented_gt = augmentation(segmentation_batch)
    # Train and do other things
_images/routing.svg
class tormentor.AugmentationChoice(aug_id=None, seed=None)[source]

Select randomly among many augmentations.

_static/example_images/AugmentationChoice.png

Random choice of perspective and plasma-brightness augmentations

augmentation_factory = tormentor.RandomPerspective ^ tormentor.RandomPlasmaBrightness
augmentation = augmentation_factory()
augmented_image = augmentation(image)