decode_heic¶
- torchvision.io.decode_heic(input: Tensor, mode: ImageReadMode = ImageReadMode.UNCHANGED) Tensor [源文件]¶
将 HEIC 图像解码为 3 维 RGB[A] Tensor。
警告
为了启用 torchvision 的 AVIF 解码功能,您需要先运行
pip install torchvision-extra-decoders
。只需安装该包,无需更新您的代码。此功能仅在 Linux 上支持,且仍处于 BETA 阶段。如有任何问题,请告知我们:https://github.com/pytorch/vision/issues/new/choose。注意 torchvision-extra-decoders 根据 LGPL 许可发布。输出 Tensor 的值通常是 uint8 类型,范围为 [0, 255]。如果图像的位深度超过 8 位,则输出 Tensor 为 uint16 类型,范围为 [0, 65535]。由于 PyTorch 中对 uint16 的支持有限,我们建议在此函数后调用
torchvision.transforms.v2.functional.to_dtype()
并设置scale=True
,将解码后的图像转换为 uint8 或 float Tensor。- 参数:
input (Tensor[1]) – 一个包含 HEIC 图像原始字节的一维连续 uint8 Tensor。
mode (str 或 ImageReadMode) – 图像转换的目标模式,例如 “RGB”。默认值为 “UNCHANGED”。有关可用模式,请参见
ImageReadMode
。
- 返回:
解码后的图像 (Tensor[image_channels, image_height, image_width])