Confuse about transform PILToTensor and ToTensor

hi, i’m working with rgb images of diabetic retinopathy dataset. since i want to train my unet model, i have to do transform first, but i confuse about which transform should i use. i’ve read the documentation of transform ToTensor and it says that it’ll return [0,1] image, so it’ll be binary input to the model? which one should i use? thanks!

No, transforms.ToTensor() will return a normalized tensors with values in the range [0, 1].
transforms.PILToTensor() will return a tensor using the same dtype and value range as the original input image.

ah get it! which one is better to use for my problem?

The more common approach is to use ToTensor to create normalized FloatTensors as you would need to transform the dtype to e.g. float32 manually otherwise.

1 Like