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 per-class counting to LineZone, create LineZoneAnnotatorMulticlass #1555

Merged
merged 5 commits into from
Oct 1, 2024

Conversation

LinasKo
Copy link
Collaborator

@LinasKo LinasKo commented Sep 29, 2024

Description

This PR adds per-class counting capabilities to LineZone.
The results can be visualized with the newly added LineZoneAnnotatorMultiClass.

Type of change

Please delete options that are not relevant.

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

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

Rigorously tested locally.

Colab

Known issues that are NOT to be addressed as part of this PR:

  1. Table isn't the best-looking. We can experiment with Pillow in the future.
  2. The table only caters to LineZone, whereas tools like PolygonZone may also want to write into it.
  3. The list of arguments is dauntingly large.
  4. The text may overflow - both horizontally and vertically
  5. There's no blacklist or whitelist for displayed classes.

Any specific deployment considerations

Docs

  • Docs updated? What were the changes:
  • in_count, out_count are now properties
  • New properties: in_count_per_class, out_count_per_class
  • New class: LineZoneAnnotatorMulticlass

@LinasKo LinasKo requested a review from onuralpszr September 29, 2024 10:26
@LinasKo
Copy link
Collaborator Author

LinasKo commented Sep 29, 2024

Hi @onuralpszr 👋

If you have some time, can you skim through this one, see if anything stands out?

@onuralpszr
Copy link
Collaborator

Hi @onuralpszr 👋

If you have some time, can you skim through this one, see if anything stands out?

Hello 👋 let me setup and try out sure

@LinasKo
Copy link
Collaborator Author

LinasKo commented Sep 29, 2024

Example results:
(Tell me if it doesn't load, or run the Colab)

out_normal_optim.mp4

@onuralpszr
Copy link
Collaborator

Example results: (Tell me if it doesn't load, or run the Colab)

out_normal.mp4

Video not loading*

@onuralpszr onuralpszr added enhancement New feature or request api: linezone LineZone API labels Sep 30, 2024
@onuralpszr
Copy link
Collaborator

My Review/Test Branch

!pip install git+https://github.com/roboflow/supervision.git@line-zone-class-test -q
!pip install ultralytics -q

Copy link
Collaborator

@onuralpszr onuralpszr left a comment

Choose a reason for hiding this comment

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

I made some optimizations I think it is better to use in this case

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 Author

LinasKo commented Oct 1, 2024

Accepted the refactor:

  1. String builder is a much better approach
  2. Not a fan of precomputing all options for positions, but it is slightly more readable
  3. Loop over In/Out is good
  4. I'm not a fan of Python ternaries - it feels like it ups the complexity for the reader, while still obviously being the same if condition, only without indentation.

At the end of the day - some subjective changes and I don't mind, and some very welcome improvements. Thank you very much @onuralpszr ! Will merge it after giving it another couple of runs.

@LinasKo LinasKo merged commit 3789f69 into develop Oct 1, 2024
9 checks passed
@LinasKo LinasKo deleted the feat/line-zone-per-class-counting branch October 1, 2024 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: linezone LineZone API enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants