MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / raw_nms

Function raw_nms

flow-python/examples/application/utils.py:149–169  ·  view source on GitHub ↗
(boxes, scores, iou_threshold=0.3)

Source from the content-addressed store, hash-verified

147
148
149def raw_nms(boxes, scores, iou_threshold=0.3):
150 if 0 == len(boxes):
151 return []
152 rects = list(boxes)
153 for i in range(len(rects)):
154 rects[i] = list(rects[i])
155 rects[i].append(scores[i])
156 rects[i].append(i)
157
158 rects.sort(key=lambda x: x[4], reverse=True)
159
160 rect_valid = [True for i in range(len(rects))]
161 for i in range(len(rects)):
162 if rect_valid[i]:
163 j = i + 1
164 while j < len(rect_valid):
165 if is_overlap_v1(rects[i], rects[j], iou_threshold):
166 rect_valid[j] = False
167 j = j + 1
168
169 return [x[5] for i, x in enumerate(rects) if rect_valid[i]]
170
171
172def nms(boxes, scores, iou_threshold=0.3):

Callers

nothing calls this directly

Calls 4

listFunction · 0.85
rangeFunction · 0.85
appendMethod · 0.80
is_overlap_v1Function · 0.70

Tested by

no test coverage detected