RandomPerspective¶
- class torchvision.transforms.RandomPerspective(distortion_scale=0.5, p=0.5, interpolation=InterpolationMode.BILINEAR, fill=0)[源代码]¶
以给定的概率对给定图像执行随机透视变换。如果图像是 torch Tensor,则预期其形状为 […, H, W],其中 … 表示任意数量的前导维度。
- 参数:
distortion_scale (float) – 控制失真程度的参数,范围从 0 到 1。默认值为 0.5。
p (float) – 图像被变换的概率。默认值为 0.5。
interpolation (InterpolationMode) – 期望的插值枚举,由
torchvision.transforms.InterpolationMode
定义。默认值为InterpolationMode.BILINEAR
。如果输入是 Tensor,则仅支持InterpolationMode.NEAREST
、InterpolationMode.BILINEAR
。相应的 Pillow 整数常量,例如PIL.Image.BILINEAR
也被接受。fill (sequence 或 number) – 变换后图像外部区域的像素填充值。默认值为
0
。如果给定一个数字,则该值分别用于所有波段。
使用
RandomPerspective
的示例- forward(img)[源代码]¶
- 参数:
img (PIL Image 或 Tensor) – 要进行透视变换的图像。
- 返回:
随机变换后的图像。
- 返回类型:
PIL Image 或 Tensor