Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cfdba39

Browse files
committedApr 15, 2019
Fix a small bug of rotate_iou_gpu: the iou between two same boxes can be
0, due to point_in_quadrilateral. A test demo is provided in test_nms_gpu.py.
1 parent 8eaa9bf commit cfdba39

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
 

‎second/core/non_max_suppression/nms_gpu.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,9 @@ def point_in_quadrilateral(pt_x, pt_y, corners):
323323
adad = ad0 * ad0 + ad1 * ad1
324324
adap = ad0 * ap0 + ad1 * ap1
325325

326-
return abab >= abap and abap >= 0 and adad >= adap and adap >= 0
326+
#return abab >= abap and abap >= 0 and adad >= adap and adap >= 0
327+
eps = -1e-6
328+
return abab - abap >= eps and abap >= eps and adad - adap >= eps and adap >= eps
327329

328330

329331
@cuda.jit('(float32[:], float32[:], float32[:])', device=True, inline=True)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from nms_gpu import rotate_iou_gpu_eval
2+
import numpy as np
3+
4+
def main():
5+
boxes = np.array([
6+
[0, 0, 1, 2., 0.1],
7+
[0, 0, .001, 2., 0.1],
8+
[0, 0, 0.1, 2., 0.5],
9+
[0, 0, 0.1, 2., -np.pi/2],
10+
])
11+
12+
ious = np.diag( rotate_iou_gpu_eval(boxes, boxes) )
13+
print(f"ious: {ious}")
14+
#old: [0. 0. 0.33333316 0. ]
15+
#new: [1. 0.99998605 0.99999934 1. ]
16+
17+
if __name__ == '__main__':
18+
main()

1 commit comments

Comments
 (1)

xuyongzhi commented on Apr 15, 2019

@xuyongzhi
Author

Fix a small bug of rotate_iou_gpu in second/core/non_max_suppression/nms_gpu.py

Please sign in to comment.