MCPcopy
hub / github.com/rbgirshick/fast-rcnn / nms

Function nms

lib/utils/nms.py:10–37  ·  view source on GitHub ↗
(dets, thresh)

Source from the content-addressed store, hash-verified

8import numpy as np
9
10def nms(dets, thresh):
11 x1 = dets[:, 0]
12 y1 = dets[:, 1]
13 x2 = dets[:, 2]
14 y2 = dets[:, 3]
15 scores = dets[:, 4]
16
17 areas = (x2 - x1 + 1) * (y2 - y1 + 1)
18 order = scores.argsort()[::-1]
19
20 keep = []
21 while order.size > 0:
22 i = order[0]
23 keep.append(i)
24 xx1 = np.maximum(x1[i], x1[order[1:]])
25 yy1 = np.maximum(y1[i], y1[order[1:]])
26 xx2 = np.minimum(x2[i], x2[order[1:]])
27 yy2 = np.minimum(y2[i], y2[order[1:]])
28
29 w = np.maximum(0.0, xx2 - xx1 + 1)
30 h = np.maximum(0.0, yy2 - yy1 + 1)
31 inter = w * h
32 ovr = inter / (areas[i] + areas[order[1:]] - inter)
33
34 inds = np.where(ovr <= thresh)[0]
35 order = order[inds + 1]
36
37 return keep

Callers 3

demoFunction · 0.85
apply_nmsFunction · 0.85
test_netFunction · 0.85

Calls

no outgoing calls

Tested by 2

apply_nmsFunction · 0.68
test_netFunction · 0.68