Open
Description
I am trying to convert a TIFF image, read in through PIL, to Pytorch tensor. I am doing this through transorms.ToTensor()
. I get the following error:
RuntimeError: shape '[1460, 1936, 5]' is invalid for input of size 5653120
The reason for the error is that the function is mistakenly extracting the number of channels as 5
.
The TiffImage.mode
is "I;16B"
. Since to_tensor
hasn't got a hard coded rule for "I;16B"
mode, it gets the number of channels using len(TiffImage.mode)
which returns the length of the string.
cc @vfdev-5