supervision icon indicating copy to clipboard operation
supervision copied to clipboard

Add per-class counting to LineZone, create LineZoneAnnotatorMulticlass

Open LinasKo opened this issue 1 year ago • 5 comments

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.

  • [x] 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

  • [x] 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 avatar Sep 29 '24 09:09 LinasKo

Hi @onuralpszr 👋

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

LinasKo avatar Sep 29 '24 10:09 LinasKo

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

onuralpszr avatar Sep 29 '24 10:09 onuralpszr

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

https://github.com/user-attachments/assets/7d48fb44-fe18-4a75-96a4-68337013c77f

LinasKo avatar Sep 29 '24 10:09 LinasKo

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

out_normal.mp4

Video not loading*

onuralpszr avatar Sep 29 '24 11:09 onuralpszr

My Review/Test Branch

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

onuralpszr avatar Sep 30 '24 14:09 onuralpszr

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 avatar Oct 01 '24 08:10 LinasKo