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

Add minimum_consecutive_frames argument to ByteTrack #1050

Conversation

rolson24
Copy link
Contributor

Description

This PR fixes #1044. I decided to implement this by keeping the base ByteTrack algorithm the same, but changing when a track gets assigned a new track_id, and only returning tracks that have valid track_ids (>= 0). This change also resets the track_id counter when a new ByteTrack object is initialized.

fix bug from PR #1035

change update_with_tensors to not return tracks with track_id < 0

reset the track_id counter when initializing a new ByteTrack object

List any dependencies that are required for this change.

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 by running ByteTrack with multiple different values of minimum_consecutive_frames and looking at the output video to see if the short, low-quality tracks were removed. In this colab notebook, you can run the video at both minimum_consecutive_frames = 1 and 5 and compare the two output videos. You can also observe the maximum track_id in every frame to see that the tracker with a minimum_consecutive_frames value of 5 has much lower values indicating that there are fewer valid tracks. The number of valid tracks is also more stable.

Any specific deployment considerations

This might require updating the documentation for ByteTrack, which I am willing to do if this is approved.

Docs

  • Docs updated?

fix bug from PR roboflow#1035

change update_with_tensors to not return tracks with track_id < 0

reset the track_id counter when initializing a new ByteTrack object

update docstring

Fix other bug from PR roboflow#1035
@rolson24 rolson24 force-pushed the add-minimum_consecutive_frames-to-bytetrack branch from e387676 to 7142d1a Compare March 26, 2024 03:53
@SkalskiP
Copy link
Collaborator

Hi @rolson24 👋🏻 Looks like there are some unresolved conflicts. Could you take care of this?

@rolson24
Copy link
Contributor Author

Yes. I need to do some more testing before it gets merged though.

@rolson24
Copy link
Contributor Author

This most recent commit fixes this issue: (#1049 (comment))

If all of the detections in a frame have low confidence, then the tracker will still return these detections, but with an empty tracker_id array. This causes issues when you try to get the track_id of one of these detections (for example, using the trace_annotator). I have fixed this by simply returning empty detections with a tracker_id array of length 0. This is the behavior of the original update_with_detections() function.

I have tested this change by creating unit tests that cover all of the possible cases for detection inputs. See this colab notebook.

@SkalskiP
Copy link
Collaborator

Hi @rolson24 👋🏻 is this ready for testing and review?

@rolson24
Copy link
Contributor Author

rolson24 commented Mar 29, 2024 via email

@rolson24
Copy link
Contributor Author

After further testing, the whole idea of using track_ids to signify whether a track is valid or not will not work. This is because joint_stracks and sub_stracks rely on track_ids to prevent duplicate tracks from being in the lists. Right now this issue is causing only one track to be initialized in each frame. We would either have to modify those functions, or instead (probably better) only mark tracks that have existed for at least minimum_consecutive_frames as being "activated". This will allow them to keep unique track_id's and also allow us to easily filter out tracks that are valid. I can implement this and test it, before submitting a new PR

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.

[ByteTrack] add minimum_consecutive_frames to limit the number of falsely assigned tracker IDs
2 participants