快捷方式

ElasticTransform

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

使用弹性变换转换张量图像。给定 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[源代码]
参数:

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

返回:

转换后的图像。

返回类型:

PIL 图像或张量

文档

访问全面的 PyTorch 开发者文档

查看文档

教程

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

查看教程

资源

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

查看资源