-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Gaussian noise transformation #6192
Comments
Hi @mjack3 thanks for the request. We do have May I know what's the difference between gaussian blur and gaussian Noise? In case they are same feel free to use |
@oke-aditya maybe the correct link is https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.GaussNoise
|
What do you think @vfdev-5 ? Is this useful to add to |
I think Salt and Pepper and Gaussian Noise are valid transforms to offer. I would probably be in favour to create them on the new API which is in progress. Wdyt? |
Seems great, salt pepper noise and gaussian Noise and probably textBook transforms. Seems nice addition to new API. |
A minimal workaround today could be the following (keeping in mind all limitations it could have): from PIL import Image
import torch
import torchvision
img = Image.open("test-image.jpg")
from torchvision.transforms import Compose, PILToTensor, ToPILImage
# Tensor GN pipeline
def gauss_noise_tensor(img):
assert isinstance(img, torch.Tensor)
dtype = img.dtype
if not img.is_floating_point():
img = img.to(torch.float32)
sigma = 25.0
out = img + sigma * torch.randn_like(img)
if out.dtype != dtype:
out = out.to(dtype)
return out
t1 = Compose([
PILToTensor(),
gauss_noise_tensor,
# For visualization purposes
ToPILImage()
])
o1 = t1(img)
import matplotlib.pyplot as plt
%matplotlib inline
plt.figure(figsize=(14, 7))
plt.subplot(121)
plt.title("Pillow")
plt.imshow(img)
plt.subplot(122)
plt.title("Tensor GN")
plt.imshow(o1) I agree that we could implement it and its variant in the transforms. |
That will the job for now |
This seems easy to do with: https://pytorch.org/docs/stable/generated/torch.normal.html ? |
It is as easy as developing a horizontal flip. However, having it already implemented would be helpful. |
🚀 The feature
Add gaussian noise transformation in the functionalities of torchvision.transforms.
Motivation, pitch
Using Normalizing Flows, is good to add some light noise in the inputs. Right now I am using albumentation for this but, would be great to use it in the torchvision library
Alternatives
Albumentation has a gaussian noise implementation
Additional context
No response
cc @vfdev-5 @datumbox
The text was updated successfully, but these errors were encountered: