Shall I use transformations on PIL Image or rather on PyTorch tensor?
My inputs are PIL images. Suppose I have the following transformation composition:
 transforms.Compose([
            transforms.RandomResizedCrop(size=224),
            transforms.RandomHorizontalFlip(),
            transforms.ToTensor()])

As most of the transforms in PyTorch can work on both PIL images and tensors, I wonder in which order I should use them. Shall I first use all the transformations possible to use on PIL images and then transform to tensor, or shall I first transform to tensor and then apply the other transformations on tensors? Is the one more effective than the other?

There's no real advantage in general to changing the order. However, there can be advantages to moving the ToTensor out of the transforms chain. Specifically, you cannot JIT transformations operating on PIL images which may have optimization impact. For this reason, it may be better to convert PIL images to tensors in your data loading code and then transform as needed. I refer you to the documentation to read more about this.
