Skip to content

Commit affa284

Browse files
cmosesescg0147glenn-jocher
authored
Refactor/reduce G/C/D/IoU if: else statements (#6087)
* Refactor the code to reduece else * Update metrics.py * Cleanup Co-authored-by: Cmos <[email protected]> Co-authored-by: Glenn Jocher <[email protected]>
1 parent 7b6938d commit affa284

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

utils/metrics.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,10 @@ def bbox_iou(box1, box2, x1y1x2y2=True, GIoU=False, DIoU=False, CIoU=False, eps=
234234
with torch.no_grad():
235235
alpha = v / (v - iou + (1 + eps))
236236
return iou - (rho2 / c2 + v * alpha) # CIoU
237-
else:
238-
return iou - rho2 / c2 # DIoU
239-
else: # GIoU https://arxiv.org/pdf/1902.09630.pdf
240-
c_area = cw * ch + eps # convex area
241-
return iou - (c_area - union) / c_area # GIoU
242-
else:
243-
return iou # IoU
244-
237+
return iou - rho2 / c2 # DIoU
238+
c_area = cw * ch + eps # convex area
239+
return iou - (c_area - union) / c_area # GIoU https://arxiv.org/pdf/1902.09630.pdf
240+
return iou # IoU
245241

246242
def box_iou(box1, box2):
247243
# https://github.com/pytorch/vision/blob/master/torchvision/ops/boxes.py

0 commit comments

Comments
 (0)