decode_avif¶
- torchvision.io.decode_avif(input: Tensor, mode: ImageReadMode = ImageReadMode.UNCHANGED) Tensor[原始碼]¶
將 AVIF 影像解碼為 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 或 float 張量。- 引數:
input (Tensor[1]) – 一個一維連續的 uint8 張量,包含 AVIF 影像的原始位元組。
mode (str 或 ImageReadMode) – 要轉換到的影像模式,例如“RGB”。預設為“UNCHANGED”。有關可用模式,請參見
ImageReadMode。
- 返回:
解碼後的影像(Tensor[影像通道, 影像高度, 影像寬度])