RandomRotation¶
- class torchvision.transforms.RandomRotation(degrees, interpolation=InterpolationMode.NEAREST, expand=False, center=None, fill=0)[來源]¶
將影像旋轉一定角度。如果影像是 torch Tensor,則應具有 […, H, W] 形狀,其中 … 表示任意數量的領先維度。
- 參數:
degrees (sequence 或 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 或 number) – 旋轉影像外部區域的像素填充值。預設值為
0
。如果給定一個數字,則該值將分別用於所有通道。
使用
RandomRotation
的範例