-
Notifications
You must be signed in to change notification settings - Fork 613
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
Use ImageProjectiveTransformV3 for TF >= 2.4.0 #2293
Use ImageProjectiveTransformV3 for TF >= 2.4.0 #2293
Conversation
@@ -37,6 +37,7 @@ def transform( | |||
transforms: TensorLike, | |||
interpolation: str = "NEAREST", | |||
fill_mode: str = "CONSTANT", | |||
fill_value: TensorLike = 0.0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea where should we put the new argument. Should we maintain backward compatibility so we have to put it in the end of args? @seanpmorgan WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this looks like the best position
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
@seanpmorgan Hi Sean, this is only for TF2.4. Our nightly version will pin to both TF2.3 and TF2.4, right? |
Trying to expand our python compatibility to be 2.3+. The wheel will be built against TF2.4 so custom-ops will need TF2.4, but everything else would be great to keep compatibility. Raising a NotImplementedError for <=2.4 is an option |
Tracking many TF core issues and PRs my opinion Is that currently TF has a quite strict policy to not backport not only features but also bug fixes from nightly/master. Patch releases are sparse and for security fixes only. So I think that we need to start to support and promote only the last official TF release. |
I can do a warning for TF<2.4 that
I am more with this proposal though, there is always a loop from "I want the new feature" -> "Please use latest TF" -> "codes does not work in latest TF" -> "Fallback to older TF" -> "I want the new feature" XD |
Often it Is more like: |
) | ||
else: | ||
fill_mode = fill_mode.upper() | ||
# TODO(WindQAQ): Get rid of the check once we drop TensorFlow < 2.4 support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we automatically/programmatically fail with https://github.com/tensorflow/addons/blob/master/setup.py#L79?
What do you think? I suppose that this kind of things will stay forever in the code 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, we can clean up the codebase as our compatibility matrix moves. See #2294
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but It could be easier if we are failing in different points in the sourfe when we move the minimal version or the single version we support. Do you understand what I meant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks I need this so much! Was going crazy over the inconsistency between the different fill options for geometric transformations :D.
The only thing I am not so sure about is whether the nearest
fill option actually does work.
There should probably be tests for the "nearest"
and "bilinear"
interpolation modes of transform
as well. Currently, the interpolation
argument is untested.
The test_bilinear
and test_uint8
tests in transform_ops_test.py
apply to rotate
only, which does make use of transform
internally, but I don't think this relation should be assumed by the test case.
The function should be transfered to official repo? There is a similar function https://github.com/tensorflow/tensorflow/blob/2a7d45c6800a99e4158526e25ec128ddd90e37f7/tensorflow/python/keras/layers/preprocessing/image_preprocessing.py#L625. |
They do not make it public. In fact, they migrate it to KPL without informing us early this year 😭 So we are just doing a fork of private API now. |
Lets see 😉 ... tensorflow/tensorflow#45742 |
Agree with the PR, though I don't want to have to wait for a response prior to 0.12 release. |
It is impossible to achieve this for 0.12 cause this will got in TF 2.5 but you can bypass the policy and depend on a private API for this case, as you want. |
Understand the TF core PR wouldn't be until TF2.5, but what do you mean depend on a private API and bypass the policy? There is no private API in this PR right? |
I meant as an alternative to maintain a (function) fork. |
interpolation: str = "NEAREST", | ||
fill_mode: str = "CONSTANT", | ||
interpolation: str = "nearest", | ||
fill_mode: str = "constant", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not break the compatibility as we always uppercase it when passing into raw ops. Just to canonicalize the documentation and arguments.
@WindQAQ Thanks for changing to lowercase. So much prettier :). Would you like me to file a PR for the missing testcases in |
It's more than welcome to do that! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks! Thanks @aaronmondal for the review!
It seems that we need to maintain the fork but if the new policy Is to maintain the public API surface minimal isn't better to handle private API occasional breakage instead of maintain fork in multiple points in the source code? |
* Use ImageProjectiveTransformV3 * Mark unsupported things for TF<2.4.0
Description
Support fill_value and nearest fill_mode with ImageProjectiveTransformV3.
Type of change
Checklist:
How Has This Been Tested?
Test new features.