-
Notifications
You must be signed in to change notification settings - Fork 246
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
base: master
Are you sure you want to change the base?
Conversation
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 |
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! Left some comments
"`bounding_box.to_dense(bounding_boxes)` before passing your boxes " | ||
"to `bounding_box.mask_invalid_detections()`." | ||
) | ||
validation.validate_bounding_boxes(bounding_boxes) |
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.
Should we consider making this public API in Keras? (Though we can keep this usage for now)
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.
Or could we trigger this with public API? E.g. keras.utils.bounding_boxes.convert_format
to self.bounding_box_format
like we do in call?
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 think need to either remove this or duplicate it here. import keras.src.layers.preprocessing.image_preprocessing.bounding_boxes
will means KerasHub will not even import for older than the latest version of keras (including the keras currently preinstalled in colab images).
We don't want that.
image_size=None, | ||
scale=None, | ||
offset=None, | ||
bounding_box_format, |
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.
should we have a default for this?
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 mean we can have same as default format used for weights, but it can vary as per user dataset.
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.
Yeah, but I think a default is still probably helpful? I see a lot of bounding_box_format="xyxy",
defaults in Keras.
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.
Our default weights are in yxyx
. But yes we can have xyxy
(torch) follows or yxyx
(tensorflow) follows this. All the tensorflow datasets will have yxyx
, I would say yxyx
would be good option.
@@ -40,12 +55,14 @@ def call(self, inputs): | |||
if self.norm_std: | |||
x = x / self._expand_non_channel_dims(self.norm_std, x) | |||
|
|||
return x | |||
return x, y |
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.
probably this should be keras.utils.pack_x_y_sample_weight(x, y, sample_weight)
?
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 still needs doing I think (otherwise you toss sample_weight).
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.
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.
image_size=None, | ||
scale=None, | ||
offset=None, | ||
bounding_box_format, |
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.
Yeah, but I think a default is still probably helpful? I see a lot of bounding_box_format="xyxy",
defaults in Keras.
@@ -40,12 +55,14 @@ def call(self, inputs): | |||
if self.norm_std: | |||
x = x / self._expand_non_channel_dims(self.norm_std, x) | |||
|
|||
return x | |||
return x, y |
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 still needs doing I think (otherwise you toss sample_weight).
"`bounding_box.to_dense(bounding_boxes)` before passing your boxes " | ||
"to `bounding_box.mask_invalid_detections()`." | ||
) | ||
validation.validate_bounding_boxes(bounding_boxes) |
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 think need to either remove this or duplicate it here. import keras.src.layers.preprocessing.image_preprocessing.bounding_boxes
will means KerasHub will not even import for older than the latest version of keras (including the keras currently preinstalled in colab images).
We don't want that.
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. |
class NonMaxSuppression(keras.layers.Layer): | ||
"""A Keras layer that decodes predictions of an object detection model. | ||
Args: | ||
bounding_box_format: The format of bounding boxes of input dataset. | ||
Refer | ||
TODO: link keras core bounding box docs | ||
Refer: | ||
for more details on supported bounding box formats. |
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.
add link to keras API
non_max_suppression
,anchor_generator
, andbox_matcher
into the modeling layers for better integration.