RandomRotation¶
- class torchvision.transforms.RandomRotation(degrees, interpolation=InterpolationMode.NEAREST, expand=False, center=None, fill=0)[source]¶按角度旋轉影像。如果影像是 PyTorch 張量,則預期其形狀為 […, H, W],其中 … 表示任意數量的前導維度。
按角度旋轉影像。如果影像是 PyTorch 張量,則預期其形狀為 […, 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, optional) – 可選的旋轉中心,(x, y)。原點是左上角。預設值是影像中心。
fill (sequence or number) – 旋轉影像外部區域的畫素填充值。預設值是
0。如果給定一個數字,則該值將用於所有波段。
使用
RandomRotation的示例