Premium problem139. Greedy Non-Maximum Suppression

Hard Locked

Given boxes (n, 4) in [x1, y1, x2, y2], scores (n,) and an IoU threshold thr, return the sorted array of kept indices:

  • repeatedly take the highest-scoring remaining box
  • drop every remaining box whose IoU with it exceeds thr
  • ties in score break by lower index

Input

boxes =
[[ 0.   0.   2.   2. ]
 [ 0.1  0.1  2.1  2.1]
 [10.  10.  12.  12. ]]
scores = [0.9 0.8 0.7]
thr = 0.5

Output

[0 2]

Premium problem

This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.

Implement solve(...)