RandomRotation¶
- class torchvision.transforms.RandomRotation(degrees, interpolation=InterpolationMode.NEAREST, expand=False, center=None, fill=0)[source]¶按角度旋转图像。如果图像是 PyTorch 张量,则预期其形状为 […, H, W],其中 … 表示任意数量的前导维度。
按角度旋转图像。如果图像是 PyTorch 张量,则预期其形状为 […, 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, optional) – 可选的旋转中心,(x, y)。原点是左上角。默认值是图像中心。
fill (sequence or number) – 旋转图像外部区域的像素填充值。默认值是
0
。如果给定一个数字,则该值将用于所有波段。
使用
RandomRotation
的示例