快捷鍵

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 (strImageReadMode) – 將圖像轉換成的模式,例如 “RGB”。預設為 “UNCHANGED”。請參閱 ImageReadMode 以取得可用模式。

回傳:

解碼後的圖像 (Tensor[image_channels, image_height, image_width])

文件

存取 PyTorch 的完整開發者文件

檢視文件

教學

取得為初學者和進階開發者提供的深入教學

檢視教學

資源

尋找開發資源並獲得問題解答

檢視資源