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.
Description
torchvision.transforms.v2.functional.gaussian_noise(and thusv2.GaussianNoise) currently stubs out PIL images:The tensor kernels already support
uint8and float inputs. We should implement the PIL kernel the same way asgaussian_blur: convert withpil_to_tensor, run the existing image kernel, then convert back withto_pil_image.Proposed change
gaussian_noisethat reusesgaussian_noise_image.pil_to_tensor).