What's the difference between ToTensor and PILToTensor transforms?

What are the differences between the transforms:

torchvision.transforms.ToTensor

and

torchvision.transforms.PILToTensor

?

1 Like

PILToTensor transforms a PIL Image to a PyTorch tensor and the resulting tensor is of the same dtype, whereas ToTensor returns a FloatTensor after normalizing in the range [0, 1].

Please also refer to the official docs for better understanding.