-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Feat/remove_noisy_segments #1885
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
base: develop
Are you sure you want to change the base?
Feat/remove_noisy_segments #1885
Conversation
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.
Hi @AlexBodner, thanks for the PR!
I've added a few comments.
Can you also please resolve the pre-commit failures in the CI?
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.
please add unit tests to remove_noisy_segments
; make sure test are parametrized; you can take inspiration from test_mask_to_rle
@@ -1481,3 +1481,102 @@ def box_iou_batch_with_jaccard( | |||
for d_idx, d in enumerate(boxes_detection): | |||
ious[d_idx, g_idx] = _jaccard(d, g, is_crowd[g_idx]) | |||
return ious | |||
|
|||
|
|||
def remove_noisy_segments( |
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.
please add unit tests to remove_noisy_segments
; make sure test are parametrized; you can take inspiration from test_mask_to_rle
Description
This PR adds the function remove_noisy_segments to supervision/detection/utils.py. This function takes a mask and removes the connected components that are far away from the main component and that also are smaller than a threshold.
No dependencies added. It uses opencv.
Type of change
How has this change been tested, please provide a testcase or example of how you tested the change?
We provide unit test cases in the corresponding test_utils.py file.
Additionally, this function has been tested over some videos of the Basketball AI project, in which some masks had several components that were not connected and weren't desired. A con of this method is that it can remove desired objects, like occluded feet.
Some examples are:
Desired removals:
Undisired removals:
Before
boston-celtics-new-york-knicks-game-4-q1-05.06-05.01-3-second-rule_unfiltered.2.1.mp4
After:
boston-celtics-new-york-knicks-game-4-q1-05.06-05.01-3-second-rule_filtered.3.1.mp4
Mask comparison:
boston-celtics-new-york-knicks-game-4-q1-05.06-05.01-3-second-rule_compare.8.1.mp4
The difference is seen in the second 2 when the ball is passed and then when the ball is thrown
Docs
I only updated docs/detection/utils.md