MCPcopy Create free account
hub / github.com/FoundationVision/ByteTrack / nms

Function nms

yolox/utils/demo_utils.py:17–44  ·  view source on GitHub ↗

Single class NMS implemented in Numpy.

(boxes, scores, nms_thr)

Source from the content-addressed store, hash-verified

15
16
17def nms(boxes, scores, nms_thr):
18 """Single class NMS implemented in Numpy."""
19 x1 = boxes[:, 0]
20 y1 = boxes[:, 1]
21 x2 = boxes[:, 2]
22 y2 = boxes[:, 3]
23
24 areas = (x2 - x1 + 1) * (y2 - y1 + 1)
25 order = scores.argsort()[::-1]
26
27 keep = []
28 while order.size > 0:
29 i = order[0]
30 keep.append(i)
31 xx1 = np.maximum(x1[i], x1[order[1:]])
32 yy1 = np.maximum(y1[i], y1[order[1:]])
33 xx2 = np.minimum(x2[i], x2[order[1:]])
34 yy2 = np.minimum(y2[i], y2[order[1:]])
35
36 w = np.maximum(0.0, xx2 - xx1 + 1)
37 h = np.maximum(0.0, yy2 - yy1 + 1)
38 inter = w * h
39 ovr = inter / (areas[i] + areas[order[1:]] - inter)
40
41 inds = np.where(ovr <= nms_thr)[0]
42 order = order[inds + 1]
43
44 return keep
45
46
47def multiclass_nms(boxes, scores, nms_thr, score_thr):

Callers 1

multiclass_nmsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected