RandomRotation¶
- class torchvision.transforms.RandomRotation(degrees, interpolation=InterpolationMode.NEAREST, expand=False, center=None, fill=0)[原始碼]¶
將影像旋轉指定角度。如果影像是torch Tensor,則預期其形狀為[…, H, W],其中…表示任意數量的前導維度。
- 引數:
degrees (sequence or number) – 選擇角度的範圍。如果 degrees 是一個數字而不是序列(例如 (min, max)),則角度範圍將是 (-degrees, +degrees)。
interpolation (InterpolationMode) – 由
torchvision.transforms.InterpolationMode定義的所需插值列舉。預設為InterpolationMode.NEAREST。如果輸入是 Tensor,則僅支援InterpolationMode.NEAREST和InterpolationMode.BILINEAR。也接受相應的 Pillow 整數常量,例如PIL.Image.BILINEAR。expand (bool, optional) – 可選的擴充套件標誌。如果為 True,則擴充套件輸出以使其足夠大以容納整個旋轉後的影像。如果為 False 或省略,則輸出影像的大小與輸入影像相同。請注意,expand 標誌假定圍繞中心旋轉且沒有平移。
center (sequence, 可選) – 可選的旋轉中心,(x, y)。原點是左上角。預設為影像的中心。
fill (sequence or number) – 旋轉影像外部區域的畫素填充值。預設為
0。如果給定一個數字,則該值分別用於所有波段。
使用
RandomRotation的示例