diff --git a/utils/utils.py b/utils/utils.py index 2b5f34cb..911d3f1a 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -401,7 +401,7 @@ def compute_loss(p, targets, model, giou_flag=True): # predictions, targets, mo pbox = torch.cat((pxy, pwh), 1) # predicted box giou = bbox_iou(pbox.t(), tbox[i], x1y1x2y2=False, GIoU=True) # giou computation lbox += (1.0 - giou).sum() if red == 'sum' else (1.0 - giou).mean() # giou loss - tobj[b, a, gj, gi] = giou.detach().type(tobj.dtype) if giou_flag else 1.0 + tobj[b, a, gj, gi] = giou.detach().clamp(0).type(tobj.dtype) if giou_flag else 1.0 if 'default' in arc and model.nc > 1: # cls loss (only if multiple classes) t = torch.zeros_like(ps[:, 5:]) # targets