Skip to content

Commit

Permalink
Refactor the code to reduece else
Browse files Browse the repository at this point in the history
  • Loading branch information
cg0147 authored and glenn-jocher committed Dec 30, 2021
1 parent 7b6938d commit 4541c41
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,14 @@ def bbox_iou(box1, box2, x1y1x2y2=True, GIoU=False, DIoU=False, CIoU=False, eps=
v = (4 / math.pi ** 2) * torch.pow(torch.atan(w2 / h2) - torch.atan(w1 / h1), 2)
with torch.no_grad():
alpha = v / (v - iou + (1 + eps))
return iou - (rho2 / c2 + v * alpha) # CIoU
else:
return iou - rho2 / c2 # DIoU
else: # GIoU https://arxiv.org/pdf/1902.09630.pdf
c_area = cw * ch + eps # convex area
return iou - (c_area - union) / c_area # GIoU
else:
return iou # IoU
return iou - (rho2 / c2 + v * alpha)
# DIoU
return iou - rho2 / c2
# GIoU https://arxiv.org/pdf/1902.09630.pdf
c_area = cw * ch + eps # convex area
return iou - (c_area - union) / c_area
# IoU
return iou


def box_iou(box1, box2):
Expand Down

0 comments on commit 4541c41

Please sign in to comment.