-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Description
🐛 Describe the bug
The second argument to the function decode_jpeg in the package torchvision.io is of the type ImageReadMode, which is an enum.
However, passing ImageReadMode.GRAY_ALPHA
or ImageReadMode.RGB_ALPHA
as the second argument to decode_jpeg results in a crash (shown below).
I am not sure if it is a bug, but the docstring of decode_jpeg does not mention this limitation.
Failing test to reproduce the crash
Running the following test in the directory test reproduces the crash.
from torchvision.io.image import ImageReadMode, read_file, decode_jpeg
def test_decode_jpeg_mode_alpha():
path_jpg = 'assets/encode_jpeg/grace_hopper_517x606.jpg'
content_tensor = read_file(path_jpg)
decode_jpeg(content_tensor, ImageReadMode.GRAY_ALPHA)
decode_jpeg(content_tensor, ImageReadMode.RGB_ALPHA)
Error message
test_image_manual_user1.py::test_decode_jpeg_mode_alpha FAILED [100%]
test/test_image_manual_user1.py:3 (test_decode_jpeg_mode_alpha)
Traceback (most recent call last):
File "/home/user1/vision/test/test_image_manual_user1.py", line 7, in test_decode_jpeg_mode_alpha
decode_jpeg(content_tensor, ImageReadMode.GRAY_ALPHA)
File "/home/user1/vision/torchvision/io/image.py", line 220, in decode_jpeg
output = torch.ops.image.decode_jpeg(input, mode.value)
File "/home/user1/anaconda3/envs/vision_cov7/lib/python3.8/site-packages/torch/_ops.py", line 175, in __call__
return self._op(*args, **kwargs or {})
RuntimeError: The provided mode is not supported for JPEG files
Versions
Collecting environment information...
PyTorch version: 1.13.0.dev20220914
Is debug build: False
CUDA used to build PyTorch: 11.3
ROCM used to build PyTorch: N/A
OS: Ubuntu 20.04.5 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.31
Python version: 3.8.13 (default, Mar 28 2022, 11:38:47) [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.15.0-46-generic-x86_64-with-glibc2.17
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Versions of relevant libraries:
[pip3] mypy==0.971
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.22.4
[pip3] torch==1.13.0.dev20220914
[pip3] torchvision==0.14.0a0+b4686f2
[conda] blas 1.0 mkl
[conda] cudatoolkit 11.3.1 h2bc3f7f_2
[conda] mkl 2022.1.0 hc2b9512_224
[conda] numpy 1.22.4 pypi_0 pypi
[conda] pytorch 1.13.0.dev20220914 py3.8_cuda11.3_cudnn8.3.2_0 pytorch-nightly
[conda] pytorch-mutex 1.0 cuda pytorch-nightly
[conda] torchvision 0.14.0a0+b4686f2 dev_0