快捷方式

rotate

torchvision.transforms.functional.rotate(img: Tensor, angle: float, interpolation: InterpolationMode = InterpolationMode.NEAREST, expand: bool = False, center: Optional[List[int]] = None, fill: Optional[List[float]] = None) Tensor[source]

依據角度旋轉影像。如果影像是 torch Tensor,預期其形狀為 […, H, W],其中 … 表示任意數量的領先維度。

參數:
  • img (PIL ImageTensor) – 要旋轉的影像。

  • angle (數字) – 旋轉角度值,以度為單位,逆時針方向。

  • interpolation (InterpolationMode) – 期望的插值枚舉,由 torchvision.transforms.InterpolationMode 定義。預設值為 InterpolationMode.NEAREST。如果輸入是 Tensor,則僅支援 InterpolationMode.NEARESTInterpolationMode.BILINEAR。也接受相應的 Pillow 整數常數,例如 PIL.Image.BILINEAR

  • expand (bool, optional) – 可選的擴展標誌。 如果為 true,則擴展輸出影像,使其足夠大以容納整個旋轉影像。 如果為 false 或省略,則使輸出影像的大小與輸入影像的大小相同。 請注意,expand 標誌假定繞中心旋轉且沒有平移。

  • center (序列, optional) – 可選的旋轉中心。 原點是左上角。 預設值是影像的中心。

  • fill (序列數字, optional) –

    轉換後的影像外部區域的像素填充值。 如果給定一個數字,則該值分別用於所有通道。

    注意

    在 torchscript 模式下,不支援單個 int/float 值,請使用長度為 1 的序列:[value, ]

返回:

旋轉後的影像。

返回類型:

PIL Image 或 Tensor

使用 rotate 的範例

轉換的說明

轉換的說明

文件

存取 PyTorch 的全面開發者文件

檢視文件

教學

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

檢視教學

資源

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

檢視資源