Composite Augmentation Types¶
- class tormentor.AugmentationCascade[source]¶
Select randomly among many augmentations.
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