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