Open adamjstewart opened 9 months ago
Hi @NicolasHug, I would like to work on this issue if it is for beginners. Can you suggest me how may I proceed? Thanks
I recently re-worked our extension compilation logic and the image.so
extension is now always built, unconditionally. It doesn't depend anymore on the existence of libjpeg or libpng (because we vendor libgif, which is always present, so we always build).
Because of this recent change, I'm having a hard time imagining a scenario where this warning is emitted and undesirable. @adamjstewart can you remind me exact the scenario where you got this warning? Was it when building from source in specific conditions? When installing the stable version?
It was when building from source, stable releases, but no libjpeg/libpng installed on the OS.
Thanks for confirming. I understand why this was causing an undesirable warning in the past. Now that we always build image.so
, I suspect this might have become a non-issue, i.e. the extension should be available and load just fine without a warning (and only contain the gif decoder).
I'm fine with closing this if you want, although I'm also hoping for an option to build with external giflib and disable that in the future.
Do you mean to dynamically link against giflib instead of statically? If so, why is that the case?
(also let me know about https://github.com/pytorch/vision/pull/8406#discussion_r1691444762 please :) )
Replied to that thread, I mean building with a non-vendored copy of giflib.
I've been looking into this a bit more. I tried using a lazy importing strategy like in https://peps.python.org/pep-0562/, so that the problematic image.so
load check is only done when when io
or io.image
get imported. Unfortunately, this doesn't really work because these modules are loaded from different places when importing torchvision
:
__init__
file we can remove it from there, but there's the other ones:torchvision.datasets
for the optical flow datasetstorchvision.transforms.v2
for the Jpeg()
transform.So, I'm afraid the only way to make this warning lazy is to only raise it when the functions are called. Which adds an extra check to each call...
🐛 Describe the bug
If no image libraries are installed, the following will warn:
I propose we only warn when importing
torchvision.io
or when using a specific function that requires one of these image libraries.Related to #7151
Versions