- Notifications
You must be signed in to change notification settings - Fork 7.2k
Closed
Description
Asking for a CYMK jpeg file to be converted to RGB by decode_jpeg() currently results in the following error:
from torchvision.io import read_file, decode_jpeg, ImageReadMode path = "test/assets/fakedata/logos/cmyk_pytorch.jpg" decode_jpeg(read_file(path), mode=ImageReadMode.RGB) # ImageReadMode.UNCHANGED would workRuntimeError: Unsupported color conversion requestThis is an important feature to support because the ImageNet dataset has ~20 CMYK images, which means we currently cannot decode ImageNet files with decode_jpeg(): we have to rely on PIL.
According to this comment in our code there should be a way to support this:
vision/torchvision/csrc/io/image/cpu/decode_jpeg.cpp
Lines 120 to 124 in 9b432d0
| /* | |
| * Libjpeg does not support converting from CMYK to grayscale etc. There | |
| * is a way to do this but it involves converting it manually to RGB: | |
| * https://github.com/tensorflow/tensorflow/blob/86871065265b04e0db8ca360c046421efb2bdeb4/tensorflow/core/lib/jpeg/jpeg_mem.cc#L284-L313 | |
| */ |
Metadata
Metadata
Assignees
Labels
No labels