Skip to content

functional : to_tensor() doesn't accommodate for PIL image mode 'I:16B'. #856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AlessandroCortex opened this issue Apr 16, 2019 · 0 comments

Comments

@AlessandroCortex
Copy link

AlessandroCortex commented Apr 16, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants