Refactor/reduce G/C/D/IoU `if: else` statements (#6087)
* Refactor the code to reduece else * Update metrics.py * Cleanup Co-authored-by: Cmos <gen.chen@ubisoft.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>pull/3630/head
parent
7b6938d5b5
commit
affa284352
|
@ -234,14 +234,10 @@ def bbox_iou(box1, box2, x1y1x2y2=True, GIoU=False, DIoU=False, CIoU=False, eps=
|
|||
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 # DIoU
|
||||
c_area = cw * ch + eps # convex area
|
||||
return iou - (c_area - union) / c_area # GIoU https://arxiv.org/pdf/1902.09630.pdf
|
||||
return iou # IoU
|
||||
|
||||
def box_iou(box1, box2):
|
||||
# https://github.com/pytorch/vision/blob/master/torchvision/ops/boxes.py
|
||||
|
|
Loading…
Reference in New Issue