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
的示例