functional : to_tensor() doesn't accommodate for PIL image mode 'I:16B'.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17.9k
- Forks
- 7.3k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 13
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the transforms.ToTensor() entry point and reproduce the failure with a PIL TIFF image whose mode is "I;16B". Trace how the channel count is determined; done means this mode no longer produces a channel count of 5 and the image converts to a tensor successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100