decode_heic¶
- torchvision.io.decode_heic(input: Tensor, mode: ImageReadMode = ImageReadMode.UNCHANGED) Tensor [source]¶
Decode an HEIC image into a 3 dimensional RGB[A] Tensor.
Warning
In order to enable the AVIF decoding capabilities of torchvision, you first need to run
pip install torchvision-extra-decoders
. Just install the package, you don’t need to update your code. This is only supported on Linux, and this feature is still in BETA stage. Please let us know of any issue: https://github.com/pytorch/vision/issues/new/choose. Note that torchvision-extra-decoders is released under the LGPL license.The values of the output tensor are in uint8 in [0, 255] for most images. If the image has a bit-depth of more than 8, then the output tensor is uint16 in [0, 65535]. Since uint16 support is limited in pytorch, we recommend calling
torchvision.transforms.v2.functional.to_dtype()
withscale=True
after this function to convert the decoded image into a uint8 or float tensor.- Parameters:
input (Tensor[1]) – a one dimensional contiguous uint8 tensor containing the raw bytes of the HEIC image.
mode (str or ImageReadMode) – The mode to convert the image to, e.g. “RGB”. Default is “UNCHANGED”. See
ImageReadMode
for available modes.
- Returns:
Decoded image (Tensor[image_channels, image_height, image_width])