How to manipulate image in a batch(after batch has been created)?

I am trying to perform a custom alignment code on batch of images from the dataloader.

The custom alignment code that I have written takes one image as a base reference and align other images based on that. My alignment code runs on cv2 python package, hence I need image format not Tensors, as returned by dataloader during training to align before sending them into the network.
Till now, I have been using a Static Image file to align images in a batch in the getitem implementation. I need to align the batch based on the very first image in the batch. It will help me to generalize better, I think.

Let me know If anyone can help me. I would be so greatful as I am facing this problem since very long and trying to figure out on my own.

You can write your own collate function. However it won’t get the advantages of multiprocessing.
Thus, you can just preprocess it before feeding it into the network by reconverting tensors in numpy.