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

Made api's compatible with python3.7+ #11259

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

bharatjetti
Copy link
Collaborator

@bharatjetti bharatjetti commented Sep 13, 2024

Description

Tensorflow_models not working when imported in python 3.9 Environment.
Added functionality to make the code backward compatible from Python3.7.

  • Python 3.9 is not compatible with | operator, which is introduced in Python3.10.
  • The typing package need to be used to implement the | functionality in Python3.9.

Reference github issue #11247 #11256

Type of change

For a new feature or function, please create an issue first to discuss it
with us before submitting a pull request.

Note: Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Tests

Test Configuration:

Checklist

@laxmareddyp laxmareddyp requested review from Chen-Zhe and removed request for rachellj218 September 13, 2024 16:28
@laxmareddyp laxmareddyp added the models:official models that come under official repository label Sep 13, 2024
@LakshmiKalaKadali
Copy link
Collaborator

Hi @yeqingli, @lehougoogle, @Chen-Zhe, could you please review the PR. Thank You

Chen-Zhe
Chen-Zhe previously approved these changes Oct 3, 2024
@laxmareddyp laxmareddyp added the ready to pull ready to pull (create internal pr review and merge automatically) label Oct 3, 2024
@laxmareddyp laxmareddyp removed the ready to pull ready to pull (create internal pr review and merge automatically) label Oct 8, 2024
@laxmareddyp laxmareddyp requested a review from Chen-Zhe October 8, 2024 17:35
Copy link
Member

@yeqingli yeqingli left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. Please updates the something | None to Optional[something].

@@ -33,7 +34,7 @@ class BaseTwoTowerUpliftNetwork(tf_keras.layers.Layer, metaclass=abc.ABCMeta):
def call(
self,
inputs: types.DictOfTensors,
training: bool | None = None,
mask: tf.Tensor | None = None,
training: Union[bool, None] = None,
Copy link
Member

Choose a reason for hiding this comment

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

I think Union[something | None] is equivalent to Optional[something]. Could you update here and all the other places if applicable.

@laxmareddyp laxmareddyp requested a review from yeqingli October 28, 2024 04:56
@@ -263,8 +263,8 @@ def build_retinanet(
l2_regularizer: Optional[tf_keras.regularizers.Regularizer] = None,
backbone: Optional[tf_keras.Model] = None,
decoder: Optional[tf_keras.Model] = None,
num_anchors_per_location: int | dict[str, int] | None = None,
anchor_boxes: Mapping[str, tf.Tensor] | None = None,
num_anchors_per_location: Union[int, Dict[str, int], None] = None,
Copy link
Member

Choose a reason for hiding this comment

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

Can this Union[int, Dict[str, int], None] be Optional[Union[int, Dict[str, int]]]

@chaoyan1037
Copy link
Collaborator

Please resolve conflicts.

@bharatjetti
Copy link
Collaborator Author

Please resolve conflicts.

Resolved conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
models:official models that come under official repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants