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

[ByteTrack] - add a method to reset the state of the tracker #827

Merged

Conversation

AdonaiVera
Copy link
Contributor

Description

This Pull Request introduces a reset method to the ByteTrack tracking system, enabling efficient processing of multiple video streams sequentially within the same execution environment. The enhancement ensures that internal tracking states such as tracked_tracks, lost_tracks, removed_tracks, and the global BaseTrack._count are reset between videos, addressing inaccuracies caused by state persistence.

The addition is particularly useful for applications requiring sequential video analysis without the overhead of restarting the Python environment, streamlining workflows in surveillance, traffic monitoring, and activity recognition.

Issue Addressed: #789

Type of Change

  • New feature (non-breaking change which adds functionality)

Testing

The implementation was tested using a new test case ultralytics_example_multiple_videos, processing multiple video streams to verify the tracker's state resets correctly. Additionally, a Google Colab demo illustrates the reset functionality in action.

output1.mp4
output2.mp4

Deployment Considerations

No specific considerations. The reset method is backward compatible and should seamlessly integrate into existing deployments.

Documentation Updates

  • Reset Method: Documented the usage and impact of the reset method within the ByteTrack class.
  • Testing Procedure: Updated the ultralytics_example_multiple_videos test case documentation to reflect the sequential video processing testing approach.

@SkalskiP
Copy link
Collaborator

Hi @AdonaiVera 👋🏻 Please drop ultralytics_example_multiple_videos script. 🙏🏻

@AdonaiVera
Copy link
Contributor Author

I just removed it @SkalskiP

@@ -261,6 +260,13 @@ def callback(frame: np.ndarray, index: int) -> np.ndarray:

return detections

def reset(self):
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 document this method? For the method to be displayed in docs it needs to be public and have docstring.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @SkalskiP Thank you for the suggestions. I have already implemented the changes. Please let me know if there is anything else that needs to be updated. 🥷 🚀

@SkalskiP
Copy link
Collaborator

I tested with your colab. Looks like it works. As I mentioned in the comment, we need a docstring for your newly added method. I also see that pre-commit is complaining about file formatting.

@SkalskiP SkalskiP added api:tracker enhancement New feature or request Q1.2024 Tasks planned for execution in Q1 2024. labels Feb 1, 2024
@SkalskiP SkalskiP linked an issue Feb 1, 2024 that may be closed by this pull request
@SkalskiP
Copy link
Collaborator

SkalskiP commented Feb 1, 2024

Thank you @AdonaiVera 🙏🏻 Awesome. I tested the solution. Everything works. Let's merge.

@SkalskiP SkalskiP merged commit 81d0c3a into roboflow:develop Feb 1, 2024
8 checks passed
@AdonaiVera AdonaiVera deleted the add_method_reset_state_tracker branch February 1, 2024 15:21
@AdonaiVera
Copy link
Contributor Author

Thank you @SkalskiP 🚀 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api:tracker enhancement New feature or request Q1.2024 Tasks planned for execution in Q1 2024.
Projects
Development

Successfully merging this pull request may close these issues.

[ByteTrack] - add a method to reset the state of the tracker
2 participants