Function to_pil_image expects wrong dtype for 'I;16' mode.
Open
Nobody has claimed this yet.
module: transforms
needs discussion
- Dominant language
- Python
- Stars
- 17.9k
- Forks
- 7.3k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 13
Description
🐛 Bug
Function to_pil_image expects wrong dtype for 'I;16' mode.
According to Pillow documentation it should accept uint16 while torchvision expects int16 to set 'I;16' and don't support uint16 ndarray (code)
To Reproduce
Steps to reproduce the behavior:
- Create uint16 ndarray with image inside
- Try to convert it to pil image.
- Get an error that input type is not supported
Expected behavior
uint16 ndarray should generate proper pil image.
Environment
- PyTorch / torchvision Version (e.g., 1.0 / 0.4.0): 1.5/ 0.6.0
- OS (e.g., Linux): Windows
- How you installed PyTorch / torchvision (
conda,pip, source): pip - Build command you used (if compiling from source):
- Python version: 3.7
- CUDA/cuDNN version: 10
- GPU models and configuration: titan rtx, titan v
- Any other relevant information:
Additional context
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 in torchvision/transforms/functional.py at the cited to_pil_image conversion around line 223, and reproduce the failure with a uint16 ndarray. Compare the accepted dtype and resulting mode with Pillow's I;16 documentation; done means a uint16 ndarray produces the expected PIL image without the unsupported-input error.
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
- Clearly specified
- Newbie friendliness
- 45/100