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

Remove bounding box utils and refactor retinanet #2039

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

Conversation

sineeli
Copy link
Collaborator

@sineeli sineeli commented Jan 8, 2025

  1. Moved non_max_suppression, anchor_generator, and box_matcher into the modeling layers for better integration.
  2. Removed redundant bounding box utilities and dependencies

@sineeli sineeli requested a review from mattdangerw January 9, 2025 16:27
@mattdangerw
Copy link
Member

mattdangerw commented Jan 13, 2025

Not sure what best to do about this test failure. @sineeli do you know the minimal version of Keras we would need for all of this?

@sineeli
Copy link
Collaborator Author

sineeli commented Jan 13, 2025

Not sure what best to do about this test failure. @sineeli do you know the minimal version of Keras we would need for all of this?

It would require latest release 3.8.0 which has iou function and box encoding utilities as well.

Copy link
Member

@mattdangerw mattdangerw left a comment

Choose a reason for hiding this comment

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

Thanks! Left some comments

keras_hub/src/layers/modeling/non_max_supression.py Outdated Show resolved Hide resolved

@keras_hub_export("keras_hub.layers.AnchorGenerator")
class AnchorGenerator(keras.layers.Layer):
"""Generates anchor boxes for object detection tasks.

Copy link
Member

Choose a reason for hiding this comment

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

these look like copy paste bugs where selecting from github removes empty newlines. bring these empty newlines back

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure

Copy link
Member

Choose a reason for hiding this comment

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

This is unfixed. Take a look at the diff here and restore the empty newlines.

If you copy paste from the github ui you will remove all empty newlines from the file, just something to watch out for.

keras_hub/src/layers/modeling/box_matcher.py Show resolved Hide resolved
keras_hub/src/layers/modeling/anchor_generator.py Outdated Show resolved Hide resolved
Copy link
Member

@mattdangerw mattdangerw left a comment

Choose a reason for hiding this comment

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

Still a few comments to address. The big one, we need to get rid of the private import of keras for that validation function. Let's remove or duplicate.

We might also want to set things up so the library still works with older keras versions, and throws an error when using an OD model that 3.8 is required. But I can help with that part.

keras_hub/src/layers/modeling/non_max_supression.py Outdated Show resolved Hide resolved
@sineeli
Copy link
Collaborator Author

sineeli commented Jan 21, 2025

Oh yeah make sense, we can only import when we have Keras>=3.8.0 version and then throw error when this doesn't satisfy? I hope this works.

@sineeli
Copy link
Collaborator Author

sineeli commented Jan 30, 2025

@mattdangerw what do you think on assert_bounding_box_support function, does it looks good or else any changes needed please let me know thanks!

@sineeli sineeli requested a review from mattdangerw January 30, 2025 21:49
@sineeli sineeli added the kokoro:force-run Runs Tests on GPU label Jan 30, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Runs Tests on GPU label Jan 30, 2025
Copy link
Member

@mattdangerw mattdangerw left a comment

Choose a reason for hiding this comment

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

Thanks! Looking good. Still a few minor things.


@keras_hub_export("keras_hub.layers.AnchorGenerator")
class AnchorGenerator(keras.layers.Layer):
"""Generates anchor boxes for object detection tasks.

Copy link
Member

Choose a reason for hiding this comment

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

This is unfixed. Take a look at the diff here and restore the empty newlines.

If you copy paste from the github ui you will remove all empty newlines from the file, just something to watch out for.

keras_hub/src/layers/modeling/anchor_generator_test.py Outdated Show resolved Hide resolved
keras_hub/src/utils/tensor_utils.py Outdated Show resolved Hide resolved
keras_hub/src/models/retinanet/retinanet_label_encoder.py Outdated Show resolved Hide resolved
@@ -40,14 +59,15 @@ def call(self, inputs):
if self.norm_std:
x = x / self._expand_non_channel_dims(self.norm_std, x)

return x
return x, y, sample_weight
Copy link
Member

Choose a reason for hiding this comment

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

call pack_x_y_sample_weight here, it will gracefully handle the no label case.

Copy link
Member

Choose a reason for hiding this comment

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

This still isn't done! Is there an issue with this one?

@sineeli sineeli added the kokoro:force-run Runs Tests on GPU label Feb 3, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Runs Tests on GPU label Feb 3, 2025
@mattdangerw
Copy link
Member

@sineeli let me know when this is ready again. I think the torch failure looks unrelated.

@sineeli sineeli added the kokoro:force-run Runs Tests on GPU label Feb 3, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Runs Tests on GPU label Feb 3, 2025
@sineeli
Copy link
Collaborator Author

sineeli commented Feb 3, 2025

@mattdangerw its done you can take a final look and merge it. Thanks for the review!!

Copy link
Member

@mattdangerw mattdangerw left a comment

Choose a reason for hiding this comment

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

Nice work! Just one last comment I see unresolved.

@@ -40,14 +59,15 @@ def call(self, inputs):
if self.norm_std:
x = x / self._expand_non_channel_dims(self.norm_std, x)

return x
return x, y, sample_weight
Copy link
Member

Choose a reason for hiding this comment

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

This still isn't done! Is there an issue with this one?

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

Successfully merging this pull request may close these issues.

4 participants