Skip to content

Fix a small bug of rotate_iou_gpu: the iou between two same boxes can be 0. #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()