RandomRotation¶
- class torchvision.transforms.RandomRotation(degrees, interpolation=InterpolationMode.NEAREST, expand=False, center=None, fill=0)[source]¶
按角度旋转图像。如果图像是 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
的示例