@@ -296,6 +296,12 @@ def decode_image(
296296    after this function to convert the decoded image into a uint8 or float 
297297    tensor. 
298298
299+     .. note:: 
300+ 
301+         ``decode_image()`` doesn't work yet on AVIF or HEIC images. For these 
302+         formats, directly call  :func:`~torchvision.io.decode_avif` or 
303+         :func:`~torchvision.io.decode_heic`. 
304+ 
299305    Args: 
300306        input (Tensor or str or ``pathlib.Path``): The image to decode. If a 
301307            tensor is passed, it must be one dimensional uint8 tensor containing 
@@ -384,6 +390,17 @@ def decode_webp(
384390# The ops (torch.ops.extra_decoders_ns.decode_*) are otherwise torchscript-able, 
385391# and users who need torchscript can always just wrap those. 
386392
393+ # TODO_AVIF_HEIC: decode_image() should work for those. The key technical issue 
394+ # we have here is that the format detection logic of decode_image() is 
395+ # implemented in torchvision, and torchvision has zero knowledge of 
396+ # torchvision-extra-decoders, so we cannot call the AVIF/HEIC C++ decoders 
397+ # (those in torchvision-extra-decoders) from there. 
398+ # A trivial check that could be done within torchvision would be to check the 
399+ # file extension, if a path was passed. We could also just implement the 
400+ # AVIF/HEIC detection logic in Python as a fallback, if the file detection 
401+ # didn't find any format. In any case: properly determining whether a file is 
402+ # HEIC is far from trivial, and relying on libmagic would probably be best 
403+ 
387404
388405_EXTRA_DECODERS_ALREADY_LOADED  =  False 
389406
@@ -423,6 +440,17 @@ def _load_extra_decoders_once():
423440def  decode_avif (input : torch .Tensor , mode : ImageReadMode  =  ImageReadMode .UNCHANGED ) ->  torch .Tensor :
424441    """Decode an AVIF image into a 3 dimensional RGB[A] Tensor. 
425442
443+     .. warning:: 
444+         In order to enable the AVIF decoding capabilities of torchvision, you 
445+         first need to run ``pip install torchvision-extra-decoders``. Just 
446+         install the package, you don't need to update your code. This is only 
447+         supported on Linux, and this feature is still in BETA stage. Please let 
448+         us know of any issue: 
449+         https://github.com/pytorch/vision/issues/new/choose. Note that 
450+         `torchvision-extra-decoders 
451+         <https://github.com/pytorch-labs/torchvision-extra-decoders/>`_ is 
452+         released under the LGPL license. 
453+ 
426454    The values of the output tensor are in uint8 in [0, 255] for most images. If 
427455    the image has a bit-depth of more than 8, then the output tensor is uint16 
428456    in [0, 65535]. Since uint16 support is limited in pytorch, we recommend 
@@ -449,6 +477,17 @@ def decode_avif(input: torch.Tensor, mode: ImageReadMode = ImageReadMode.UNCHANG
449477def  decode_heic (input : torch .Tensor , mode : ImageReadMode  =  ImageReadMode .UNCHANGED ) ->  torch .Tensor :
450478    """Decode an HEIC image into a 3 dimensional RGB[A] Tensor. 
451479
480+     .. warning:: 
481+         In order to enable the AVIF decoding capabilities of torchvision, you 
482+         first need to run ``pip install torchvision-extra-decoders``. Just 
483+         install the package, you don't need to update your code. This is only 
484+         supported on Linux, and this feature is still in BETA stage. Please let 
485+         us know of any issue: 
486+         https://github.com/pytorch/vision/issues/new/choose. Note that 
487+         `torchvision-extra-decoders 
488+         <https://github.com/pytorch-labs/torchvision-extra-decoders/>`_ is 
489+         released under the LGPL license. 
490+ 
452491    The values of the output tensor are in uint8 in [0, 255] for most images. If 
453492    the image has a bit-depth of more than 8, then the output tensor is uint16 
454493    in [0, 65535]. Since uint16 support is limited in pytorch, we recommend 
0 commit comments