-2

I'm using yolov5 for object detection and I want to remove bounding boxes that are almost contained within each other. In my case a small bbox is contained into a big bbox. So IoU is small and cannot be used to remove this case. Actually this happened while I had a small iou for inference, hence my question

Example of nested bounding boxes

I've seen that there is an agnostic parameter but as mentioned in a previous issue it's only for "different classes" and here my two bbox comes from the same class.

Any help is appreciated

Timothee W
  • 149
  • 7
  • 1
    this is usually grouped under "non-maximum suppression", although working with bounding boxes is downstream from "maxima". you just need to pairwise compare your boxes and calculate overlap as some sensible measure, like intersection over union. – Christoph Rackwitz Aug 16 '23 at 07:25
  • @ChristophRackwitz thank you for your answer ! This seems pretty slow but if I have no other option i'll do just that – Timothee W Aug 16 '23 at 08:28
  • well it's slow if you actually do the cartesian product of a LOT of rectangles. if you have A LOT of them, use sensible data structures like quadtrees, or suitable algorithms like the "scanline" algorithm (boxes/polygons are first sorted along one axis, then further processing). this is now a computer graphics problem. – Christoph Rackwitz Aug 16 '23 at 09:46
  • also, this isn't actually a problem because it's solved. whatever deep learning library you use will have a solution for cleaning up a set of overlapping boxes. – Christoph Rackwitz Aug 16 '23 at 09:47
  • As mentionned in the title i'm using Yolov5 and it doesn't handle it. As mentionned it has iou but it's not helpful for this problem – Timothee W Aug 16 '23 at 10:00
  • https://stackoverflow.com/a/76825491/2602877 – Christoph Rackwitz Aug 16 '23 at 11:17
  • I'm aware of this but as mentioned in my post "it's only for "different classes" and here my two bbox comes from the same class." – Timothee W Aug 16 '23 at 12:04
  • I know and you misunderstand. it's supposed to handle overlapping boxes for the same class. – Christoph Rackwitz Aug 16 '23 at 12:16

0 Answers0