Skip to content

Commit 50f303f

Browse files
author
yixu.cui
committed
plus eps on h1 and h2
1 parent dd9f79f commit 50f303f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

utils/general.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ def bbox_iou(box1, box2, x1y1x2y2=True, GIoU=False, DIoU=False, CIoU=False, eps=
375375
if DIoU:
376376
return iou - rho2 / c2 # DIoU
377377
elif CIoU: # https://github.com/Zzh-tju/DIoU-SSD-pytorch/blob/master/utils/box/box_utils.py#L47
378-
v = (4 / math.pi ** 2) * torch.pow(torch.atan(w2 / h2) - torch.atan(w1 / h1), 2)
378+
# v = (4 / math.pi ** 2) * torch.pow(torch.atan(w2 / h2) - torch.atan(w1 / h1), 2)
379+
v = (4 / math.pi ** 2) * torch.pow(torch.atan(w2 / (h2 + eps)) - torch.atan(w1 / (h1 + eps)), 2)
379380
with torch.no_grad():
380381
alpha = v / (v - iou + (1 + eps))
381382
return iou - (rho2 / c2 + v * alpha) # CIoU

0 commit comments

Comments
 (0)