Data augmentation for segmentation task

I have some input images and labels(also images) I need perform segmentation on input images. I want to augment my training dataset before feeding it to UNet, I need to perform same transform(like ‘HorizontalFlip’ or ‘RandomRotation’) for both input image and label image, I am confused about how to get same transform for input image and label image since all transform function operate at random probabilities.
Please help.
Thanks

2 Likes

You could have a look at the discussion over in the torchvision repository.



2 Likes

For random rotation ,you can do this:

x=int (np.random.uniform(0,360,1))
image=image.rorate(image,x)
label=label.rorate(label,x)

1 Like