Skip to content
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

Support extended mode on projective transform #1721

Conversation

WindQAQ
Copy link
Member

@WindQAQ WindQAQ commented Apr 23, 2020

Closed #1318. Support extend mode on projective transform. Mainly follow the scipy's implementation.

From top to bottom: original, reflect, constant, mirror, nearest, wrap. Addons is on the left, scipy is on the right.

test

Testing script:

import numpy as np

import tensorflow as tf
import tensorflow_addons as tfa

from scipy import ndimage, misc

image = misc.face()

tf.io.write_file("test.jpeg", tf.io.encode_jpeg(image))

for mode in ["CONSTANT", "REFLECT", "WRAP", "MIRROR", "NEAREST"]:
    t = tfa.image.rotate(image, np.pi / 4, extend=mode)
    tf.io.write_file(mode.lower() + ".jpeg", tf.io.encode_jpeg(t))
    st = ndimage.rotate(image, 45, mode=mode.lower(), reshape=False)
    tf.io.write_file("scipy-" + mode.lower() + ".jpeg", tf.io.encode_jpeg(st))

@bot-of-gabrieldemarmiesse

@mels630

You are owner of some files modified in this pull request.
Would you kindly review the changes whenever you have the time to?
Thank you very much.

@WindQAQ WindQAQ requested a review from a team April 23, 2020 23:16
@WindQAQ WindQAQ changed the title Image/support extended mode on projective transform Support extended mode on projective transform Apr 23, 2020
@AakashKumarNain
Copy link
Member

AakashKumarNain commented Apr 24, 2020

@WindQAQ overall looking good but I have one query. Please check the inline comments I have made

@WindQAQ
Copy link
Member Author

WindQAQ commented Apr 24, 2020

Just figure out that there is another PR #1719. @srilman what do you think about this :-) Thank you.

@srilman
Copy link

srilman commented Apr 25, 2020

@WindQAQ Looks great to me! Definitely preferable to #1719. Only thing is that it would be nice if the different extended modes could be used separately (outside of projective transforms) for more flexibility.

For example, I mentioned that I liked to extend the image before performing some image ops like tf.image.random_crop. In general, extend can be used in lieu of tf.image.resize_with_pad in nearly every situation.

@WindQAQ
Copy link
Member Author

WindQAQ commented Apr 25, 2020

@WindQAQ Looks great to me! Definitely preferable to #1719. Only thing is that it would be nice if the different extended modes could be used separately (outside of projective transforms) for more flexibility.

For example, I mentioned that I liked to extend the image before performing some image ops like tf.image.random_crop. In general, extend can be used in lieu of tf.image.resize_with_pad in nearly every situation.

We can have both of them actually if they are both useful :-)

@WindQAQ WindQAQ requested a review from a team April 29, 2020 19:01
@WindQAQ
Copy link
Member Author

WindQAQ commented May 4, 2020

@bhack It seems that it is migrated to core TF in Jan. I have no idea about this. Thanks for pointing out!

cc @tensorflow/sig-addons-maintainers

tensorflow/tensorflow@2699281

@WindQAQ
Copy link
Member Author

WindQAQ commented May 4, 2020

@WindQAQ I know that I am blamed as the cross-linking guy

Never mind 😄 I don't even care about it LOL. Your links are super helpful for me.

but I suppose it was part of a more general effort that we already commented at #1226 (comment) and in some follow-up messages in that thread mentioning Keras.

Umm, it seems to be the miscommunication between us and many places. A related issue has been posted #1779. Thanks again for pointing out it :-)

@bhack
Copy link
Contributor

bhack commented May 5, 2020

@WindQAQ Users are looking for some of these filling parameters at tensorflow/tensorflow#39177

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.

tfa.image.rotate Different Fill Modes
6 participants