Skip to content

torch.ops.image.decode_image(called from torchvision.io.read_image) crashes python on this image #4485

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

Closed
you74674 opened this issue Sep 26, 2021 · 3 comments

Comments

@you74674
Copy link

🐛 Describe the bug

torchvision.io.read_image crashes python when reading this image(from 300W/lfpw/trainset dataset).
There's no error message, but it looks like the crash happens in torch.ops.image.decode_image.
I have tested it on three different computer(0.10.0, 0.10.1 and 0.10.1+cpu), and all of them crashed.

from PIL import Image
import numpy as np
img = np.array(Image.open('image_0779.png'))#this is fine
import torchvision
torchvision.io.read_image('image_0779.png')#this crash

image_0779

Versions

Collecting environment information...
PyTorch version: 1.9.1+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Microsoft Windows 10 Home Insider Preview
GCC version: Could not collect
Clang version: Could not collect
CMake version: version 3.21.2
Libc version: N/A

Python version: 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.21296-SP0
Is CUDA available: True
CUDA runtime version: 11.1.74

GPU models and configuration: GPU 0: NVIDIA TITAN Xp COLLECTORS EDITION
Nvidia driver version: 510.10
cuDNN version: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin\cudnn_ops_train64_8.dll
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] Could not collect
[conda] Could not collect

@prabhat00155
Copy link
Contributor

On Mac, this throws the following error:

RuntimeError: At most 8-bit PNG images are supported currently.

Your image has a bit-depth of 16, which is currently not supported.
That said, it should not crash your Python. I'll try to reproduce this on Windows.

@prabhat00155
Copy link
Contributor

prabhat00155 commented Sep 26, 2021

Thanks for reporting the bug. I was able to reproduce this issue with 0.10 on Windows. However, I think this issue is same as #3613 which was fixed in #4101. If you try the latest nightly(conda install pytorch torchvision cpuonly -c pytorch-nightly), you wouldn't see the crash with the correct exception thrown.

@you74674
Copy link
Author

Oh, searching with read_image didn't give me that issue. I have to search with torchvision.io.read_image.
Thank you for the explanation and solution.

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