Skip to content

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

Open
@AlessandroCortex

Description

@AlessandroCortex

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions