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

feat: Add minimum_box_area_ratio to filter out poor, partial boxes #2484

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

Conversation

thomas-coldwell
Copy link
Contributor

@thomas-coldwell thomas-coldwell commented Aug 29, 2024

What does this PR do?

This PR adds logic to the bounding_box.clip_to_image to attenuate the boxes that fall below a certain threshold of their original area in an image. This is particularly useful when creating a training dataset and wanting to ensure partial elements of an object that could now belong to any class e.g. a foot are not detected as a particular class leading to a noisy output during inference.

This can be tested with the jittered resize demo by setting this value to 0.95 (most boxes will be filtered out as at least 5% has been cropped / clipped out) and then setting it to 0.0 which will make it behave as before.

@divyashreepathihalli and @sampathweb

Fixes # (issue)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue? Please add a link
    to it if that's the case.
  • Did you write any new necessary tests?
  • If this adds a new model, can you run a few training steps on TPU in Colab to ensure that no XLA incompatible OP are used?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@@ -103,6 +103,7 @@ def __init__(
crop_size=None,
bounding_box_format=None,
interpolation="bilinear",
minimum_box_area_ratio=0.0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

let us remove this from the augmentation layers. We need to keep this consistent with the other layers. Let us not touch this.

Copy link
Collaborator

@divyashreepathihalli divyashreepathihalli 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 PR! Left a few comments!

@@ -23,6 +23,7 @@ def main():
target_size=(512, 512),
scale_factor=(3 / 4, 4 / 3),
bounding_box_format="xyxy",
minimum_box_area_ratio=0.5
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove this as well. Maybe add a doc string to clip_to_image, explain the args and add an example there

clipped_bounding_boxes = bounding_box.convert_format(
clipped_bounding_boxes,
source="rel_xyxy",
target=bounding_box_format,
images=images,
image_shape=image_shape,
)
passed = ops.logical_and(areas > 0.0, area_ratios > minimum_box_area_ratio)
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we rename passed to something more meaningful - valid_box maybe?

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.

3 participants