torchvision/transforms/functional.py", line 743, in to_grayscale
    raise TypeError('img should be PIL Image. Got {}'.format(type(img)))
TypeError: img should be PIL Image. Got <class 'torch.Tensor'>

Hello, I understand the error. However, this should not happen. Transformation toGrayScale accepts both PIL images and Tensors according to the documentation. Also, this error only comes up on my machine and it doesn’t while running my script on Google Colab.