updates
This commit is contained in:
parent
51d666a81a
commit
77012f8f97
|
@ -272,9 +272,11 @@ def bbox_iou(box1, box2, x1y1x2y2=True, GIoU=False, DIoU=False, CIoU=False):
|
|||
rho2 = ((b2_x1 + b2_x2) - (b1_x1 + b1_x2)) ** 2 / 4 + ((b2_y1 + b2_y2) - (b1_y1 + b1_y2)) ** 2 / 4
|
||||
if DIoU:
|
||||
return iou - rho2 / c2 # DIoU
|
||||
elif CIoU:
|
||||
elif CIoU: # https://github.com/Zzh-tju/DIoU-SSD-pytorch/blob/master/utils/box/box_utils.py#L47
|
||||
v = (4 / math.pi ** 2) * torch.pow(torch.atan(w2 / h2) - torch.atan(w1 / h1), 2)
|
||||
return iou - (rho2 / c2 + v ** 2 / (1 - iou + v)) # CIoU
|
||||
with torch.no_grad():
|
||||
alpha = v / (1 - iou + v)
|
||||
return iou - (rho2 / c2 + v * alpha) # CIoU
|
||||
|
||||
return iou
|
||||
|
||||
|
|
Loading…
Reference in New Issue