mirror of
https://github.com/THU-MIG/yolov10.git
synced 2025-05-23 05:24:22 +08:00
fix val with half
This commit is contained in:
parent
cf32e2f7f0
commit
8f0984817d
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user