I am working on an optical flow algorithm, where the input is 2 images of size HxWx3 and the target is a tensor of size HxWx2. To do data augmentation, I need to apply the same random transformation to all the 3 tensors. Take this augmentation for example:
aug_transforms = transforms.Compose([ transforms.RandomHorizontalFlip(), transforms.RandomResizedCrop((614, 216), scale=(0.1, 1.0)), transforms.RandomRotation(17), transforms.RandomVerticalFlip(), transforms.RandomApply([transforms.ColorJitter()]) ])
The torchvision transforms accept PIL object as an input. To solve this problem I have two questions:
- Can we save the random state of a given transform, so that we can apply the same randomness to img1, img2 and the flow ?
- Can we combine all the date into a PIL object, apply transformation and retrieve back the same tensors values range we had at the beginning ?