You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# TODO_AVIF_HEIC: Better support for torchscript. Scripting decode_avif of
# decode_heic currently fails, mainly because of the logic
# _load_extra_decoders_once() (using global variables, try/except statements,
# etc.).
# The ops (torch.ops.extra_decoders_ns.decode_*) are otherwise torchscript-able,
# and users who need torchscript can always just wrap those.
# TODO_AVIF_HEIC: decode_image() should work for those. The key technical issue
# we have here is that the format detection logic of decode_image() is
# implemented in torchvision, and torchvision has zero knowledge of
# torchvision-extra-decoders, so we cannot call the AVIF/HEIC C++ decoders
# (those in torchvision-extra-decoders) from there.
# A trivial check that could be done within torchvision would be to check the
# file extension, if a path was passed. We could also just implement the
# AVIF/HEIC detection logic in Python as a fallback, if the file detection
# didn't find any format. In any case: properly determining whether a file is
# HEIC is far from trivial, and relying on libmagic would probably be best
Torchscript support isnt' that important especially consider the op themselves support torchscript. Support in decode_image() is more important. Some update since the comment was written: there might be a way to call the C++ AVIF/HEIC decoders from within the C++ implementation of decode_image: simply calling the dispatcher like
auto dispatcher = torch::Dispatcher::singleton();
dispatcher.call("extra_decoders_ns::decode_heic", ...);
Need to investigate this.
The text was updated successfully, but these errors were encountered:
HEIC and AVIF decoders are now publicly available. Some improvements we can make are:
decode_image()
More of that is documented here:
vision/torchvision/io/image.py
Lines 386 to 402 in f7b1cfa
Torchscript support isnt' that important especially consider the op themselves support torchscript. Support in
decode_image()
is more important. Some update since the comment was written: there might be a way to call the C++ AVIF/HEIC decoders from within the C++ implementation ofdecode_image
: simply calling the dispatcher likeNeed to investigate this.
The text was updated successfully, but these errors were encountered: