[go: nahoru, domu]

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

New feature HeatmapAnnotator #466

Merged
merged 5 commits into from
Oct 18, 2023
Merged

Conversation

kapter
Copy link
@kapter kapter commented Oct 12, 2023

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
supervision/annotators/core.py Outdated Show resolved Hide resolved
@AlainPilon
Copy link

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
Copy link
Author
kapter commented Oct 15, 2023

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

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
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

@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
Copy link
Author
kapter commented Oct 18, 2023

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
Copy link
Author
kapter commented Oct 18, 2023

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

@AlainPilon
Copy link

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
Copy link
Author
kapter commented Oct 18, 2023

In our example heatmap based on tracks is not interesting.

output

iIn last commit 90 value added well named parameters.

@kapter
Copy link
Author
kapter commented Oct 18, 2023

Preview

walking-reference-heatmap2.mov

@SkalskiP
Copy link
Collaborator

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

@SkalskiP
Copy link
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
5 of 6 checks passed
@kapter
Copy link
Author
kapter commented Oct 19, 2023

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.

None yet

4 participants