tlpss / keypoint-detection

2D keypoint detection with Pytorch Lightning and wandb
MIT License
70 stars 9 forks source link

AP breaks for predictions with same probability #41

Closed brambozz closed 7 months ago

brambozz commented 8 months ago

Hi!

I'm working on a 2D detection problem (bubble detection in ultrasound) and was looking for an AP implementation which thresholds on distance instead of IoU. Your implementation was exactly that, so thanks!

I noticed if I generate predictions with the same probability, I actually get a PR curve with many points, where I expected only one point. The source is I think this line, where points are ordered according to probability. When points have the same probability they will still be ordered randomly, whereas they should be processed as a group and give 1 precision/recall value.

Not sure if this matters in practice though, as predictions maybe never will have exactly the same probability :)

tlpss commented 8 months ago

Hi @brambozz, thanks for the feedback!

Not sure if this matters in practice though, as predictions maybe never will have exactly the same probability :)

Yes I believe the impact is limited as this won't occur (often).

When points have the same probability they will still be ordered randomly, whereas they should be processed as a group and give 1 precision/recall value.

I had never thought of this edge case actually. But what you are saying makes sense! I would have to find another implementation of mAP calculation and see how they are handling this (e.g. Coco). If you dig deeper into this, feel free to let me know what you find! Otherwise I will keep it in mind and look into it when I have some time :+1:

brambozz commented 8 months ago

Yes, that makes sense! Currently, I think for me it is also not really an issue. I ended up adapting a bit from this repository, because I knew it from a PhD colleague (https://github.com/DIAGNijmegen/picai_eval/tree/main) which uses the sklearn implementation for a similar scenario.

I think in your comments you already said that using that function is an option.

tlpss commented 7 months ago

I think in your comments you already said that using that function is an option.

Yes that seems like a good alternative!