Trying to implement data augmentation into a semantic segmentation training, I tried to apply some transformations to the same image and mask. If I rotate the image, I need to rotate the mask as well. The thing is RandomRotation, RandomHorizontalFlip, etc. use random seeds.
I read somewhere this seeds are generated at the instantiation of the transforms. I’m trying to figure out how to ensure that both image and mask are transformed in the same way. This is a “simple” example of the workflow I’ve tried, which results in image and mask with different rotations.
Hi @ptrblck , this does not work for me. For example, let us take random rotation. If I set angle to a definite value, the same rotation happens to both mask and image. But if I set random angle or random probability to image and still pass same angle, the transformation looks different in mask and image. Please help.
It should show the same angle and would thus rotate both images with it.
If that’s the case your plot might show the images in a wrong order or you might be shuffling the images somewhere afterwards.
If plotting is the problem, then I would not get the right output when I set angle deterministically. i.e if I set angle = 52.3 for example without using random and plot it, I see the following correct output-
So you have confirmed that indeed the same angle is used for both rotations and that the plotting is not an issue. In this case the correspondence between input and target seems to be broken somewhere else and we might need a minimal and executable code snippet to reproduce and isolate the issue.