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

Fix Cost Matrix containing NaN Values in ByteTrack #1180

Merged
merged 2 commits into from
May 24, 2024

Conversation

rolson24
Copy link
Contributor

@rolson24 rolson24 commented May 8, 2024

Description

This change fixes issue #458. The object tracker was not able to handle detections that had a bounding box area of zero. I fixed this by filtering out the bounding boxes that have an area of zero in update_with_tensors().

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

I tested this change by deliberately sending boxes with an area of 0 into the tracker. The tracker was able to handle this by simply ignoring those detections. Colab notebook with test code.

@LinasKo
Copy link
Collaborator

LinasKo commented May 16, 2024

Hi @rolson24 👋

Well done isolating the error and finding the root cause!

What prompted me to dig for other solutions was the removal of class_id, boxes, etc. The algorithm downstream should be able to handle whatever comes its way, and more broadly - we had issues with similar approaches before.

There is a more concise solution, in fact. In detection/utils.py, there's a function box_iou_batch. Inside it, unsafe division is causing all of these NaN values. I reckon, instead of returning, it should first do ious = np.nan_to_num(ious).

Would you have some time to update it? 😉

Also, are the test in the Colab the same as in #1077?

@LinasKo
Copy link
Collaborator

LinasKo commented May 23, 2024

I've added the NaN conversion at the point IOUs are calculcated.

The same Colab as provided showcases the fix.

@SkalskiP
Copy link
Collaborator

Hi, @rolson24 and @LinasKo! Thanks a lot! 🙏🏻 @rolson24
The work you did to find the source of the problem was crucial.
However, I think the solution proposed by @LinasKo is more advantageous. I am surprised that our IoU calculation code did not account for the possibility of a box having zero area.

@SkalskiP SkalskiP merged commit ad7e643 into roboflow:develop May 24, 2024
9 checks passed
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.

None yet

3 participants