Do the same transformations on a list of PIL Image

I have a dataset of around 200 images. However, the format of my image is not standard because it has 6 dimensions.

One image would look like this (before being cast to tensor and being stack in a 3d Tensor):

[img0, img1, img2, img3, img4, img5]. (They are all grayscale PIL Image )

However my dataset is quite small and I want to do upsampling. I wanted to use torchvisions.transforms to do that. My problem is that I need to perform the exact same list of transformation (like RandomHorizontalFlip, Random Rotation, etc…) for all the dimension of my image and but I do not want to do the same transformation for every image. Is there a way to do so?

You could use the functional API of torchvision.transforms as given in this example.
This would make sure to apply the same “random” transformation on all image slices.
Let me know, if this would work for you.

1 Like

Yes I found your example. It worked thank you very much.