Skip to content

Commit

Permalink
update python nms
Browse files Browse the repository at this point in the history
  • Loading branch information
lufficc committed Jul 12, 2019
1 parent bc52228 commit 2706d2b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions ssd/utils/nms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def boxes_nms(boxes, scores, nms_thresh, max_count=-1):
""" Performs non-maximum suppression, run on GPU or CPU according to
boxes's device.
Args:
boxes(Tensor): `xyxy` mode boxes, use absolute coordinates(not support relative coordinates),
shape is (n, 4)
boxes(Tensor): `xyxy` mode boxes, use absolute coordinates(or relative coordinates), shape is (n, 4)
scores(Tensor): scores, shape is (n, )
nms_thresh(float): thresh
max_count (int): if > 0, then only the top max_proposals are kept after non-maximum suppression
Expand Down
6 changes: 3 additions & 3 deletions ssd/utils/python_nms.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def python_nms(boxes, scores, nms_thresh):
y1 = boxes[:, 1]
x2 = boxes[:, 2]
y2 = boxes[:, 3]
areas = (x2 - x1 + 1) * (y2 - y1 + 1)
areas = (x2 - x1) * (y2 - y1)
order = np.argsort(scores)[::-1]
num_detections = boxes.shape[0]
suppressed = np.zeros((num_detections,), dtype=np.bool)
Expand All @@ -47,8 +47,8 @@ def python_nms(boxes, scores, nms_thresh):
yy1 = max(iy1, y1[j])
xx2 = min(ix2, x2[j])
yy2 = min(iy2, y2[j])
w = max(0, xx2 - xx1 + 1)
h = max(0, yy2 - yy1 + 1)
w = max(0, xx2 - xx1)
h = max(0, yy2 - yy1)

inter = w * h
ovr = inter / (iarea + areas[j] - inter)
Expand Down

0 comments on commit 2706d2b

Please sign in to comment.