Skip to content

Support PIL images in v2.GaussianNoise #9652

Description

@YeonwooSung

Description

torchvision.transforms.v2.functional.gaussian_noise (and thus v2.GaussianNoise) currently stubs out PIL images:

raise ValueError("Gaussian Noise is not implemented for PIL images.")

The tensor kernels already support uint8 and float inputs. We should implement the PIL kernel the same way as gaussian_blur: convert with pil_to_tensor, run the existing image kernel, then convert back with to_pil_image.

Proposed change

  • Register a PIL kernel for gaussian_noise that reuses gaussian_noise_image.
  • Document that PIL images are supported (uint8 path via pil_to_tensor).
  • Replace the current negative PIL test with a positive one.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions