Apply same transformation to x and y

I’m working on a Semantic Segmentation problem. I would want to create a custom transformation “randomRotation” that rotates an image (input or output) 90, 180, or 270 degrees randomly. Due to the nature of the problem It is compulsory that each pair of images (input and output) to be rotated the same number of degrees.

Anybody could shed some light on the problem?

When you create your Databunch using the DataBlock API, you have the possibility to do it by passing tfm_y=True when you call .transform()

For example:
(src.transform(get_transforms(), size=size, tfm_y=True)

Take a look at the notebook of the Lesson on segmentation.

1 Like