随机旋转¶
- class torchvision.transforms.RandomRotation(degrees, interpolation=InterpolationMode.NEAREST, expand=False, center=None, fill=0)[source]¶
旋转图像的角度。 如果图像是torch张量,它应该具有[…, H, W]形状,其中…表示任意数量的前导维度。
- Parameters:
degrees (sequence 或 number) – 选择的角度范围。 如果 degrees 是一个数字而不是像 (min, max) 这样的序列,那么角度范围将是 (-degrees, +degrees)。
插值 (InterpolationMode) – 由
torchvision.transforms.InterpolationMode定义的所需插值枚举。默认值为InterpolationMode.NEAREST。 如果输入是张量,则仅支持InterpolationMode.NEAREST和InterpolationMode.BILINEAR。 也接受相应的Pillow整数常量,例如PIL.Image.BILINEAR。expand (bool, optional) – 可选的扩展标志。 如果为true,则扩展输出以使其足够大以容纳整个旋转后的图像。 如果为false或省略,则使输出图像与输入图像大小相同。 请注意,expand标志假设围绕中心旋转且没有平移。
center (sequence, optional) – 可选的旋转中心,(x, y)。原点是左上角。 默认是图像的中心。
fill (sequence 或 number) – 旋转图像外部区域的像素填充值。默认值为
0。如果给定一个数字,则该值将分别用于所有波段。
使用
RandomRotation的示例: