Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function to_pil_image expects wrong dtype for 'I;16' mode. #2322

Open
kuzemchik opened this issue Jun 15, 2020 · 1 comment
Open

Function to_pil_image expects wrong dtype for 'I;16' mode. #2322

kuzemchik opened this issue Jun 15, 2020 · 1 comment

Comments

@kuzemchik
Copy link

馃悰 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:

  1. Create uint16 ndarray with image inside
  2. Try to convert it to pil image.
  3. 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

@fmassa
Copy link
Member

fmassa commented Jul 7, 2020

Hi @kuzemchik

This is indeed a problem, and is accentuated given that PyTorch doesn't accept uint16 types, only int16, so this would only partially be supported (via numpy). This would make ToPILImage(ToTensor(pil_image)) not the identity, as we don't support uint16 types. I'm not sure there is a good alternative here, but I'm open for feedback.

For context, support for int16 was added in #122, and there is quite some early discussion about it in #105.

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