-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Add RandomGaussianBlur #2635
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
Comments
Hi @tejank10 thanks for asking and proposing to work on this issue.
In general it is better to avoid adding new dependencies (like
Technically, this feature can be a bit complex for a first-time contributors but I can help/guide and directly iterate on sent PR etc. There will be two implementations, see as example What do you think ? |
Thanks for the direction @vfdev-5. I was comparing PIL's GaussianBlur functionality with the ones from other libraries. This will help in designing the transform for torch.Tensor and mitigate the possible inconsistencies between PIL vs tensor outputs. PIL's GaussianBlur performs BoxFilter thrice to approximate GaussianBlur. It takes While designing the blur for torch.Tensor should we go about it the OpenCV way, or try to match PIL since we plan to use PIL's version when PIL Image as input? |
@tejank10 for the first version I think PIL's GaussianBlur with a single parameter
Please, take a look how implemented |
@vfdev-5 Yeah I understand that using any other library is not the way. :) |
@tejank10 yes we are OK with that tradeoff and let the function perform the same as PIL. |
Glad to see someone is working on this! It would be better for me if the function is to be as controllable as that of OpenCV. class GaussianBlur():
def __init__(self, kernel_size, sigma_min=0.1, sigma_max=2.0):
self.sigma_min = sigma_min
self.sigma_max = sigma_max
self.kernel_size = kernel_size
def __call__(self, img):
sigma = np.random.uniform(self.sigma_min, self.sigma_max)
img = cv2.GaussianBlur(np.array(img), (self.kernel_size, self.kernel_size), sigma)
return Image.fromarray(img.astype(np.uint8))
transform = transforms.Compose([
...,
transforms.RandomApply([GaussianBlur(kernel_size=23)], p=0.1),
...,
]) In summary, I hope we can provide:
|
@yaox12 thanks for the suggestion, let's see what could we do. |
This is how it currently looks. It randomly chooses a kernel radius from the given range, creates kernel accordingly, and applies the blurring function. Following is the error image between PIL vs Tensor versions when I tried it on the hopper image: Let me know your thoughts, @vfdev-5 , @yaox12 on what could be possible improvements. |
@tejank10 sorry for delayed reply. Could you please draft a PR based on your branch and we can iterate over the code. |
Closed via #2658 |
Uh oh!
There was an error while loading. Please reload this page.
🚀 Feature
Idea is to add a random gaussian blur image transform like in SwAV
cc @vfdev-5
The text was updated successfully, but these errors were encountered: