Skip to content

Commit eaa5ecf

Browse files
AlexWang1900glenn-jocher
andauthoredJul 29, 2020
* fix ultralytics#541 ultralytics#542 * Update train.py Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
1 parent d027bc6 commit eaa5ecf

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
 

‎train.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def train(hyp, tb_writer, opt, device):
377377

378378
# Save last, best and delete
379379
torch.save(ckpt, last)
380-
if (best_fitness == fi) and not final_epoch:
380+
if best_fitness == fi:
381381
torch.save(ckpt, best)
382382
del ckpt
383383
# end epoch ----------------------------------------------------------------------------------------------------

‎utils/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ def bbox_iou(box1, box2, x1y1x2y2=True, GIoU=False, DIoU=False, CIoU=False):
346346
elif CIoU: # https://github.com/Zzh-tju/DIoU-SSD-pytorch/blob/master/utils/box/box_utils.py#L47
347347
v = (4 / math.pi ** 2) * torch.pow(torch.atan(w2 / h2) - torch.atan(w1 / h1), 2)
348348
with torch.no_grad():
349-
alpha = v / (1 - iou + v)
350-
return iou - (rho2 / c2 + v * alpha) # CIoU
349+
alpha = v / (1 - iou + v + 1e-16)
350+
return iou - (rho2 / c2 + v * alpha ) # CIoU
351351

352352
return iou
353353

0 commit comments

Comments
 (0)