Skip to content

Added gaussian_blur_op #1450

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

Merged
merged 84 commits into from
Apr 30, 2020
Merged

Added gaussian_blur_op #1450

merged 84 commits into from
Apr 30, 2020

Conversation

ghosalsattam
Copy link
Contributor

@ghosalsattam ghosalsattam commented Mar 27, 2020

This PR is aimed at putting a gaussian blur in an image. It reduces the noise in an image.
See Issue #1333

@ghosalsattam
Copy link
Contributor Author

@seanpmorgan @gabrieldemarmiesse @WindQAQ @autoih Please provide a review

@Squadrick
Copy link
Member

Squadrick commented Mar 27, 2020

@ghosalsattam This is PR requires some more work to get to an acceptable state. I'll work you through the steps:

  1. You shouldn't put the file in the base directory, put in under tensorflow_addons/image.
  2. Update BUILD in tensorflow_addons/image.
  3. The naming scheme of files should be file_name.py, not fileName.py.
  4. You've implemented the op as an object, whereas it should actually be implemented as a function. See some of the other ops in tensorflow_addons/image to get a better idea.
  5. You should use tf for the implementation instead of np. (ones, expand_dims).
  6. All core TF ops should be used via the public API. So use tf.nn.convolution directly. Remove all tensorflow.python.* imports. This is because tensorflow.python.* imports are private.
  7. The testing code should run using pytest.
  8. The test should compare the output with other standard image processing libraries like PIL or sklearn-image.

@Squadrick Squadrick mentioned this pull request Mar 27, 2020
@ghosalsattam
Copy link
Contributor Author

@Squadrick I am trying to use tf.Tensor to find Gaussian Kernel.But when I am using the function assign in a variable of type tf.Variable I am getting the error 'tensorflow.python.framework.ops.EagerTensor' object has no attribute 'assign'
Can you please help me with the problem as I am new to tensorflow open source community.
Thank You

@Squadrick
Copy link
Member

@ghosalsattam Can you post the code that's causing the error.

@ghosalsattam
Copy link
Contributor Author

Ok

@ghosalsattam
Copy link
Contributor Author

ghosalsattam commented Mar 27, 2020

def findKernel(sigma,kSize,gaussianFilter):

	"This function creates a kernel of size [kSize*kSize]"
	for i in range(-kSize//2,kSize//2+1):
		for j in range(-kSize//2,kSize//2+1):
			gaussianFilter[i+kSize//2][j+kSize//2].assign(1/(2*np.pi*(sigma)**2)*np.exp(-(i**2+j**2)/(2*sigma**2)))
	print(gaussianFilter)
	return

gaussianFilter=tf.Variable(tf.zeros([5,5]))
findKernel(1,5,gaussianFilter)

@ghosalsattam
Copy link
Contributor Author

@Squadrick Please help with the code I provided above

@ghosalsattam
Copy link
Contributor Author

Ok I solved it. Thank you for the support and sorry for the inconvenience caused.

@ghosalsattam
Copy link
Contributor Author

@Squadrick plaese provide a review.

@ghosalsattam
Copy link
Contributor Author

@seanpmorgan @gabrieldemarmiesse @WindQAQ @autoih @Squadrick Please provide a review

@ghosalsattam
Copy link
Contributor Author

Fixes Issue #1353

@gabrieldemarmiesse
Copy link
Member

@ghosalsattam we usually provide review when all the tests in the CI are passing. Here you have some failed tests. You can look at the logs by clicking on "details".

@rmlarsen
Copy link
Member

rmlarsen commented Apr 29, 2020 via email

@rmlarsen
Copy link
Member

rmlarsen commented Apr 29, 2020 via email

@bhack
Copy link
Contributor

bhack commented Apr 29, 2020

@rmlarsen I don't know if also the device specific knowledge it is going to play a role in the transform stack.

@bhack
Copy link
Contributor

bhack commented Apr 29, 2020

@rmlarsen P.s. I don't know if we have already this device specific knowledge or we need to waiting for something like a more advanced machine retargetability in MLIR

@rmlarsen
Copy link
Member

rmlarsen commented Apr 29, 2020 via email

@bhack
Copy link
Contributor

bhack commented Apr 29, 2020

@rmlarsen @alextp Do you think it makes sense to track part of this in a new issue on the TF repo or is it not interesting enough for other use cases?

@ghosalsattam
Copy link
Contributor Author

@bhack For now what should I do to this PR in order for it to be brought to merging state?

@bhack
Copy link
Contributor

bhack commented Apr 29, 2020

@ghosalsattam I think that you could use the 2d kernel here for merging and that you could track this on a DepthwiseConv2D specific issue on the TF repo after waiting for TF team feedback to see if the topic has a "general enough public".

@ghosalsattam
Copy link
Contributor Author

And for CPU?

@bhack
Copy link
Contributor

bhack commented Apr 29, 2020

@ghosalsattam I think you can ignore the device and that it is better that DepthwiseConv2D will have directly this knowledge instead of having conditions here in the op so it knows how to propagate down the stack.
In proposal ticket on TF I hope that you could ask to pass the rank=1/separability arg directly (or something similar to inform it about the separate filter).

@ghosalsattam
Copy link
Contributor Author

ghosalsattam commented Apr 29, 2020 via email

@ghosalsattam
Copy link
Contributor Author

ghosalsattam commented Apr 29, 2020

@bhack Can it be merged now?

@bhack
Copy link
Contributor

bhack commented Apr 29, 2020

You need to wait for a reviewer with write power.

@ghosalsattam
Copy link
Contributor Author

@WindQAQ Can it be merged now?

@ghosalsattam
Copy link
Contributor Author

@WindQAQ I have addressed all your changes. Can it be merged now?

@bhack
Copy link
Contributor

bhack commented Apr 30, 2020

@rmlarsen @alextp The feature request for Tensorflow is at tensorflow/tensorflow#39050. Please close it if you evaluate that it is not relevant enough.

@ghosalsattam
Copy link
Contributor Author

ghosalsattam commented Apr 30, 2020

@bhack According to me this should be implemented in all other conv ops where this situation may arise like along wiith depthwise conv operation- Conv2D, Conv3D,...
(If at all implementation is needed).

@WindQAQ WindQAQ self-requested a review April 30, 2020 18:36
Copy link
Member

@WindQAQ WindQAQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for the contribution.

@WindQAQ WindQAQ merged commit a6b4671 into tensorflow:master Apr 30, 2020
@ghosalsattam
Copy link
Contributor Author

@ALL I learnt many new things from this contribution and cant wait for having new contributions. Thanx for your support.

@rmlarsen
Copy link
Member

rmlarsen commented May 1, 2020

@ghosalsattam Thanks for the contribution!

ashutosh1919 pushed a commit to ashutosh1919/addons that referenced this pull request Jul 12, 2020
* Gaussian Blur op

* Adds Average smoothing op

* Gaussian Filter

* Delete averageSmoothing.py

remove averageSmoothing.py

* Delete averageSmoothing_test.py

* Delete gaussianBlur_ops.py

* Delete gaussianBlur_ops_test.py

* Delete gaussianBlur_ops_test.py

* improved test

* improved test

* added main

* gaussian

* test for gaussian Blur

* after flake test

* python black

* Codeowners

* BUILD

* __init__

* gaussian_blur

* ci test

* github check

* github check

* github check

* github test

* github check

* github check

* github check

* git check

* github check

* github check

* check

* check

* ci check

* check

* test

* check

* test

* github check

* github check

* ci test

* github check

* github check

* github check

* github check

* github check

* Changed the kernel computing technique

* github test

* github check

* github check

* github test

* github check

* Shifted to filters.py

* changed codeowners

* revert codeowners changes

* changed codeowners

* codeowners

* Changed TO NHWC format

* github check

* Update filters.py

* github check

* Github Check

* new commit

* increased flexibility of kernel_size

* added name parameter for the gaussian blur op

* changed documentation

* update __init__.py

* Added 2D convolution Along with sequence of 1D convolution

* Added experimental_compile

* revert

* github check

* githun check
jrruijli pushed a commit to jrruijli/addons that referenced this pull request Dec 23, 2020
* Gaussian Blur op

* Adds Average smoothing op

* Gaussian Filter

* Delete averageSmoothing.py

remove averageSmoothing.py

* Delete averageSmoothing_test.py

* Delete gaussianBlur_ops.py

* Delete gaussianBlur_ops_test.py

* Delete gaussianBlur_ops_test.py

* improved test

* improved test

* added main

* gaussian

* test for gaussian Blur

* after flake test

* python black

* Codeowners

* BUILD

* __init__

* gaussian_blur

* ci test

* github check

* github check

* github check

* github test

* github check

* github check

* github check

* git check

* github check

* github check

* check

* check

* ci check

* check

* test

* check

* test

* github check

* github check

* ci test

* github check

* github check

* github check

* github check

* github check

* Changed the kernel computing technique

* github test

* github check

* github check

* github test

* github check

* Shifted to filters.py

* changed codeowners

* revert codeowners changes

* changed codeowners

* codeowners

* Changed TO NHWC format

* github check

* Update filters.py

* github check

* Github Check

* new commit

* increased flexibility of kernel_size

* added name parameter for the gaussian blur op

* changed documentation

* update __init__.py

* Added 2D convolution Along with sequence of 1D convolution

* Added experimental_compile

* revert

* github check

* githun check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.