From a209a32019da7fee6c4d3209b0950f951c58ec5d Mon Sep 17 00:00:00 2001 From: AlexWang1900 <60679873+AlexWang1900@users.noreply.github.com> Date: Wed, 29 Jul 2020 09:31:01 +0800 Subject: [PATCH] Fix bug #541 #542 (#545) * fix #541 #542 * Update train.py Co-authored-by: Glenn Jocher --- train.py | 2 +- utils/utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/train.py b/train.py index 086ae26..e10d5b9 100644 --- a/train.py +++ b/train.py @@ -377,7 +377,7 @@ def train(hyp, tb_writer, opt, device): # Save last, best and delete torch.save(ckpt, last) - if (best_fitness == fi) and not final_epoch: + if best_fitness == fi: torch.save(ckpt, best) del ckpt # end epoch ---------------------------------------------------------------------------------------------------- diff --git a/utils/utils.py b/utils/utils.py index fda9934..8a4aae2 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -346,8 +346,8 @@ def bbox_iou(box1, box2, x1y1x2y2=True, GIoU=False, DIoU=False, CIoU=False): 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) with torch.no_grad(): - alpha = v / (1 - iou + v) - return iou - (rho2 / c2 + v * alpha) # CIoU + alpha = v / (1 - iou + v + 1e-16) + return iou - (rho2 / c2 + v * alpha ) # CIoU return iou