Skip to content

Commit

Permalink
fix val with half
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslahm committed May 30, 2024
1 parent cf32e2f commit 8f09848
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ultralytics/utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def box_iou(box1, box2, eps=1e-7):
(torch.Tensor): An NxM tensor containing the pairwise IoU values for every element in box1 and box2.
"""

# NOTE: need float32 to get accurate iou values
box1 = torch.as_tensor(box1, dtype=torch.float32)
box2 = torch.as_tensor(box2, dtype=torch.float32)
# inter(N,M) = (rb(N,M,2) - lt(N,M,2)).clamp(0).prod(2)
(a1, a2), (b1, b2) = box1.unsqueeze(1).chunk(2, 2), box2.unsqueeze(0).chunk(2, 2)
inter = (torch.min(a2, b2) - torch.max(a1, b1)).clamp_(0).prod(2)
Expand Down

0 comments on commit 8f09848

Please sign in to comment.