Skip to content

Fix point filtering logic in load_valid_labels() #157

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ry-immr
Copy link

@ry-immr ry-immr commented Jan 21, 2025

This PR addresses the filtering issue in the load_valid_labels() function, where element-wise filtering can disrupt the 2D structure of coordinate pairs (Issue #156).

Currently:

valid_points = points[(points >= 0) & (points <= 1)].reshape(-1, 2)

This element-wise approach can cause inconsistent row structures. To fix this, we can adopt row-wise filtering:

valid_points = points[np.all((points >= 0) & (points <= 1), axis=1)]

This fix ensures that x-y coordinate pairs remain intact.

However, filtering out each point individually can still break bounding boxes that include coordinates outside [0, 1]. To address this more fundamentally, I propose clipping any out-of-range coordinates to [0, 1] whenever at least one point of the bounding box lies within the frame. If all points are completely outside the frame, we ignore the bounding box as invalid. This approach preserves as much of the bounding box as possible.

Visualization of filtered bounding boxes (representing heads):

  • Current filtering logic:
    Image

  • Fixed filtering logic:
    Image

I look forward to your feedback on this change. Thank you!

@henrytsui000
Copy link
Member

Thank you for your Pull Request! It really fixes some potential bugs.

Would you be willing to change the pull request to the dataset branch?

Best regards,
Henry Tsui

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.

2 participants