decode_heic¶
- torchvision.io.decode_heic(input: Tensor, mode: ImageReadMode = ImageReadMode.UNCHANGED) Tensor [原始碼]¶
將 HEIC 影像解碼為 3 維 RGB[A] 張量。
警告
為了啟用 torchvision 的 AVIF 解碼功能,您需要先執行
pip install torchvision-extra-decoders
。只需安裝套件,您無需更新程式碼。這僅在 Linux 上支援,且此功能仍處於 BETA 階段。如有任何問題,請告知我們:https://github.com/pytorch/vision/issues/new/choose。請注意,torchvision-extra-decoders 是在 LGPL 授權下發布的。對於大多數影像,輸出張量的值為 uint8,範圍在 [0, 255] 之間。如果影像的位元深度超過 8,則輸出張量為 uint16,範圍在 [0, 65535] 之間。由於 pytorch 中對 uint16 的支援有限,我們建議在此函數之後呼叫
torchvision.transforms.v2.functional.to_dtype()
並使用scale=True
,以將解碼後的影像轉換為 uint8 或浮點張量。- 參數:
input (Tensor[1]) – 一維連續 uint8 張量,其中包含 HEIC 影像的原始位元組。
mode (str 或 ImageReadMode) – 將影像轉換成的模式,例如 “RGB”。預設為 “UNCHANGED”。請參閱
ImageReadMode
以取得可用的模式。
- 傳回:
解碼後的影像 (Tensor[image_channels, image_height, image_width])