Skip to content

Commit

Permalink
Fix a small bug of rotate_iou_gpu: the iou between two same boxes can be
Browse files Browse the repository at this point in the history
0, due to point_in_quadrilateral. A test demo is provided in
test_nms_gpu.py.
  • Loading branch information
xuyongzhi committed Apr 15, 2019
1 parent 8eaa9bf commit cfdba39
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion second/core/non_max_suppression/nms_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@ def point_in_quadrilateral(pt_x, pt_y, corners):
adad = ad0 * ad0 + ad1 * ad1
adap = ad0 * ap0 + ad1 * ap1

return abab >= abap and abap >= 0 and adad >= adap and adap >= 0
#return abab >= abap and abap >= 0 and adad >= adap and adap >= 0
eps = -1e-6
return abab - abap >= eps and abap >= eps and adad - adap >= eps and adap >= eps


@cuda.jit('(float32[:], float32[:], float32[:])', device=True, inline=True)
Expand Down
18 changes: 18 additions & 0 deletions second/core/non_max_suppression/test_nms_gpu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from nms_gpu import rotate_iou_gpu_eval
import numpy as np

def main():
boxes = np.array([
[0, 0, 1, 2., 0.1],
[0, 0, .001, 2., 0.1],
[0, 0, 0.1, 2., 0.5],
[0, 0, 0.1, 2., -np.pi/2],
])

ious = np.diag( rotate_iou_gpu_eval(boxes, boxes) )
print(f"ious: {ious}")
#old: [0. 0. 0.33333316 0. ]
#new: [1. 0.99998605 0.99999934 1. ]

if __name__ == '__main__':
main()

1 comment on commit cfdba39

@xuyongzhi
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.