Community

Join the PyTorch developer community to contribute, learn, and get your questions answered.

Community Stories

Learn how our community solves real, everyday machine learning problems with PyTorch.

Developer Resources

Find resources and get questions answered

Events

Find events, webinars, and podcasts

Forums

A place to discuss PyTorch code, issues, install, research

Models (Beta)

Discover, publish, and reuse pre-trained models

class torchvision.transforms. GaussianBlur ( kernel_size , sigma = (0.1, 2.0) ) [source]

Blurs image with randomly chosen Gaussian blur. If the image is torch Tensor, it is expected to have […, C, H, W] shape, where … means an arbitrary number of leading dimensions.

Parameters :
  • kernel_size ( int or sequence ) – Size of the Gaussian kernel.

  • sigma ( float or tuple of python:float ( min , max ) ) – Standard deviation to be used for creating kernel to perform blurring. If float, sigma is fixed. If it is tuple of float (min, max), sigma is chosen uniformly at random to lie in the given range.

  • Returns :

    Gaussian blurred version of the input image.

    Return type :

    PIL Image or Tensor

    Examples using GaussianBlur :

    Illustration of transforms

    Illustration of transforms
    forward ( img : Tensor ) Tensor [source]
    Parameters :

    img ( PIL Image or Tensor ) – image to be blurred.

    Returns :

    Gaussian blurred image

    Return type :

    PIL Image or Tensor

    static get_params ( sigma_min : float , sigma_max : float ) float [source]

    Choose sigma for random gaussian blurring.

    Parameters :
  • sigma_min ( float ) – Minimum standard deviation that can be chosen for blurring kernel.

  • sigma_max ( float ) – Maximum standard deviation that can be chosen for blurring kernel.

  • Returns :

    Standard deviation to be passed to calculate kernel for gaussian blurring.

    Return type :

    float

    For web site terms of use, trademark policy and other policies applicable to The PyTorch Foundation please see www.linuxfoundation.org/policies/ . The PyTorch Foundation supports the PyTorch open source project, which has been established as PyTorch Project a Series of LF Projects, LLC. For policies applicable to the PyTorch Project a Series of LF Projects, LLC, please see www.lfprojects.org/policies/ .