快捷方式

ElasticTransform

class torchvision.transforms.ElasticTransform(alpha=50.0, sigma=5.0, interpolation=InterpolationMode.BILINEAR, fill=0)[source]

使用弹性变换转换张量图像。给定 alpha 和 sigma,它将根据随机偏移量为所有像素生成位移向量。Alpha 控制位移的强度,sigma 控制位移的平滑度。位移被添加到身份网格,并使用生成的网格从图像中进行 grid_sample。

应用

随机转换图像中的对象形态,并产生一种“水下”效果。

参数:
  • alpha (floatsequence of python:floats) – 位移幅度。默认为 50.0。

  • sigma (floatsequence of python:floats) – 位移平滑度。默认为 5.0。

  • interpolation (InterpolationMode) – 由 torchvision.transforms.InterpolationMode 定义的所需插值枚举。默认为 InterpolationMode.BILINEAR。如果输入是 Tensor,则只支持 InterpolationMode.NEARESTInterpolationMode.BILINEAR。也接受相应的 Pillow 整数常量,例如 PIL.Image.BILINEAR

  • fill (sequencenumber) – 转换后图像外部区域的像素填充值。默认为 0。如果给定一个数字,该值将分别用于所有通道。

使用 ElasticTransform 的示例

转换图示

转换图示
forward(tensor: Tensor) Tensor[source]
参数:

tensor (PIL ImageTensor) – 要转换的图像。

返回:

转换后的图像。

返回类型:

PIL 图像或张量

文档

访问全面的 PyTorch 开发者文档

查看文档

教程

为初学者和高级开发者提供深入的教程

查看教程

资源

查找开发资源并让您的问题得到解答

查看资源