Table of Contents
Shortcuts

# ElasticTransform

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

  Transform a tensor image with elastic transformations. Given alpha and sigma, it will generate displacement vectors for all pixels based on random offsets. Alpha controls the strength and sigma controls the smoothness of the displacements. The displacements are added to an identity grid and the resulting grid is used to grid_sample from the image.

  Applications:

    Randomly transforms the morphology of objects in images and produces a see-through-water-like effect.

  Parameters:

    - alpha (float or sequence of python:floats) – Magnitude of displacements. Default is 50.0.

    - sigma (float or sequence of python:floats) – Smoothness of displacements. Default is 5.0.

    - interpolation (InterpolationMode) – Desired interpolation enum defined by `torchvision.transforms.InterpolationMode`. Default is `InterpolationMode.BILINEAR`. If input is Tensor, only `InterpolationMode.NEAREST`, `InterpolationMode.BILINEAR` are supported. The corresponding Pillow integer constants, e.g. `PIL.Image.BILINEAR` are accepted as well.

    - fill (sequence or number) – Pixel fill value for the area outside the transformed image. Default is `0`. If given a number, the value is used for all bands respectively.

  forward(tensor: Tensor) → Tensor
    Parameters:

      tensor (PIL Image or Tensor) – Image to be transformed.

    Returns:

      Transformed image.

    Return type:

      PIL Image or Tensor

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.