Skip to content

New feature HeatmapAnnotator - #466

Merged
SkalskiP merged 5 commits into
roboflow:developfrom
kapter:addHeatmapAnnotator
Oct 18, 2023
Merged

SkalskiP merged 5 commits into
roboflow:developfrom
kapter:addHeatmapAnnotator

Conversation

@kapter

@kapter kapter commented Oct 12, 2023 •

Copy link
Copy Markdown

Description

Annotator for drawing heatmap on an image using provided detections.
Heat is accumulated over time. Drawn as a semi-transparent overlay as blured circles.

Demo

walking-reference-heatmap.mov

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Docs

  • Docs updated? What were the changes:

@onuralpszr onuralpszr added this to the version: 0.16.0 milestone Oct 12, 2023
@onuralpszr onuralpszr added enhancement New feature or request API:annotator Annotators hacktoberfest Open for contributions during the annual Hacktoberfest event, aimed at encouraging open-source parti version: 0.16.0 Feature to be added in `0.16.0` release labels Oct 12, 2023
Comment thread supervision/annotators/core.py Resolved
@AlainPilon

Copy link
Copy Markdown

Very cool. Looking at this annotator makes me wonder if they shouldnt accept a kwarg to configure the annotator behaviour or if the expectation is for the dev to overwrite these classes and customize them as they need.

In the above example, being able to configure the decay would be pretty important to make it useful outside of a demo. Ex: using a very long decay (like 8 hours) on a parking lot could show cars who use the parking illegally or the spots which are the most/least popular.

I can think of a tons of use for this but they would all require fine grain control over the behaviour of the heat map.

@kapter

kapter commented Oct 15, 2023

Copy link
Copy Markdown
Author

Thanks for response.
You can get annotator attribute heatmask. This ndarray consist info about counts of detections in every pixel.
I will try this on long video from road-parking.

@AlainPilon

Copy link
Copy Markdown

Is'nt the 90 on this line used for the decay? (havnet had enough time to look over the whole thing)
https://github.com/kapter/supervision/blob/1324cda60080884d8c867dd44288aca285f5a250/supervision/annotators/core.py#L159C16-L159C44

Just giving access to this variable (as a float) would be an easy solution.

@SkalskiP

Copy link
Copy Markdown
Collaborator

Hi @AlainPilon 👋🏻 wanna propose some changes? I will probably work on merging this annotator tomorrow. So if you have some ideas how to change implementation this is good time :)

@AlainPilon

Copy link
Copy Markdown

@SkalskiP nothing I can personally fix in the next few days. A quick change would have been to move the decay value into the signature but I feel that if we start doing this, we will end up with 20 kwargs to control every aspect of the annotator.

A better solution would be to split the apparence of the annotator and its behaviour into 2 config objects but it is not something I can work on for a while. On the positive side, I do have to create a custom annotator for work which is going to use this pattern so, once I am done, I could retrofit the change in this one.

@kapter

kapter commented Oct 18, 2023

Copy link
Copy Markdown
Author

I think the main purpose of the annotator is to give a quick representation of the frequency of objects appearing in a particular part of the frame. It seems there is no need to complicate it.

@kapter

kapter commented Oct 18, 2023

Copy link
Copy Markdown
Author

I found this
image
May be later add option: track vs detection heat map?

@AlainPilon

Copy link
Copy Markdown

To me, the example you showed is a mix of tracking the movement over a long duration + the heat map with a small decay. Visualization of a parking lot comes to mind and would be a great use case for this.

I agree that for a first version of the feature, a simple version could work. But since Supervision is a framework it has to be open to the multiple potential usage. This openness could be with configuration options OR by making it very easy to overwrite existing annotators.

I have nothing against the current version of the class, other than thinking the 90 value should be a well named constant or a params. Because right now it is a magic number and unless you run some maths, it is very hard to figure out ahead of time the behaviour of the heat value over time.

@kapter

kapter commented Oct 18, 2023

Copy link
Copy Markdown
Author

In our example heatmap based on tracks is not interesting.

output

iIn last commit 90 value added well named parameters.

@kapter

kapter commented Oct 18, 2023

Copy link
Copy Markdown
Author

Preview

walking-reference-heatmap2.mov

@SkalskiP

Copy link
Copy Markdown
Collaborator

I'm merging this later today! We are releasing supervision-0.16.0 tomorrow. 🔥

@SkalskiP

Copy link
Copy Markdown
Collaborator

Merging! We need to update the docs. But I'll do it myself! 🔥 Thank you @kapter! 🙏🏻

@SkalskiP SkalskiP added the hacktoberfest-accepted Contribute to the notion of open-source this October! label Oct 18, 2023
@SkalskiP
SkalskiP merged commit 871968a into roboflow:develop Oct 18, 2023
@kapter

kapter commented Oct 19, 2023

Copy link
Copy Markdown
Author

Thank you, @SkalskiP, for your assessment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API:annotator Annotators enhancement New feature or request hacktoberfest Open for contributions during the annual Hacktoberfest event, aimed at encouraging open-source parti hacktoberfest-accepted Contribute to the notion of open-source this October! version: 0.16.0 Feature to be added in `0.16.0` release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants