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

Vectorize line zone #1228

Merged
merged 10 commits into from
Jun 5, 2024
Merged

Vectorize line zone #1228

merged 10 commits into from
Jun 5, 2024

Conversation

tc360950
Copy link
Contributor

@tc360950 tc360950 commented May 24, 2024

Description

This is a follow-up to 1205.
In this PR I've vectorized LineZone to achieve better performance.

As previously all three approaches (the one from develop, the one from 1205, and the one from this PR)
have been run on Yolov8m + ByteTrack + LineZone run 10 times on market square video.
This time I've also checked what happens when all detections are duplicated X times (resulting in a larger number of tracked objects).
The total time each LineZone version takes to compute on all frames is (seconds):

Version / Number of duplicates 1 (no duplicates) 2 4 8
develop 11.1 33 77 164
previous PR 0.71 1.7 3.1 5.53
This PR (vectorized version of develop 1.17 2.7 5 8.7

As you can see the one from previous PR always "wins" but I find the difference small enough, especially if you find this version more readable.

Type of change

Please delete options that are not relevant.

  • Optimization (non-breaking change which optimizes existing feature)

@SkalskiP
Copy link
Collaborator

Hi @tc360950 👋🏻
Considering your results and analyzing the increase in code complexity, I definitely lean towards choosing this PR over #1205.

@LinasKo
Copy link
Collaborator

LinasKo commented May 31, 2024

Hi @tc360950,

What's the best way to test this? Is there a Colab we can use?

@LinasKo
Copy link
Collaborator

LinasKo commented Jun 1, 2024

I did some basic verification with this code: https://colab.research.google.com/drive/1rA0wXfaPlGnGKzn6wVA_x01jcX9Dr8Gu?usp=sharing

I see no regressions, after testing with vehicles and people-walking videos.
I ran the updated tests from #1206 and it behaves identically, passing the current tests and failing on V-shape motions.

@tc360950, if you have a better test, let us know 😉

supervision/detection/line_zone.py Outdated Show resolved Hide resolved
supervision/detection/line_zone.py Outdated Show resolved Hide resolved
supervision/detection/line_zone.py Outdated Show resolved Hide resolved
supervision/detection/line_zone.py Outdated Show resolved Hide resolved
supervision/detection/line_zone.py Outdated Show resolved Hide resolved
@LinasKo
Copy link
Collaborator

LinasKo commented Jun 1, 2024

Hey @tc360950,

I've submitted some review comments. The changes are very small - if you can finish by Tuesday, there's a very high chance we'd include this in the next release! 🚀

@tc360950
Copy link
Contributor Author

tc360950 commented Jun 4, 2024

I did some basic verification with this code: https://colab.research.google.com/drive/1rA0wXfaPlGnGKzn6wVA_x01jcX9Dr8Gu?usp=sharing

I see no regressions, after testing with vehicles and people-walking videos. I ran the updated tests from #1206 and it behaves identically, passing the current tests and failing on V-shape motions.

@tc360950, if you have a better test, let us know 😉

I actually went a little further - I've pasted the vectorized version into a notebook and compared results to the old implementation after every frame:
https://colab.research.google.com/drive/14tPYRcgFo9-WZSppEt7pDB_djRmDQHqG?usp=sharing

@LinasKo
Copy link
Collaborator

LinasKo commented Jun 5, 2024

This is awesome. A very high quality contribution.
I've had a look at the colab - it's indeed a very thorough test.

Thank you very much!

@LinasKo LinasKo merged commit 59c5ab5 into roboflow:develop Jun 5, 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.

3 participants