updates
This commit is contained in:
parent
043a0e457c
commit
59de209ab2
|
@ -391,15 +391,15 @@ def compute_loss(p, targets, model): # predictions, targets, model
|
||||||
if nb: # number of targets
|
if nb: # number of targets
|
||||||
ng += nb
|
ng += nb
|
||||||
ps = pi[b, a, gj, gi] # prediction subset corresponding to targets
|
ps = pi[b, a, gj, gi] # prediction subset corresponding to targets
|
||||||
tobj[b, a, gj, gi] = 1.0 # obj
|
|
||||||
# ps[:, 2:4] = torch.sigmoid(ps[:, 2:4]) # wh power loss (uncomment)
|
# ps[:, 2:4] = torch.sigmoid(ps[:, 2:4]) # wh power loss (uncomment)
|
||||||
|
|
||||||
# GIoU
|
# GIoU
|
||||||
pxy = torch.sigmoid(ps[:, 0:2]) # pxy = pxy * s - (s - 1) / 2, s = 1.5 (scale_xy)
|
pxy = torch.sigmoid(ps[:, 0:2]) # pxy = pxy * s - (s - 1) / 2, s = 1.5 (scale_xy)
|
||||||
pwh = torch.exp(ps[:, 2:4]).clamp(max=1E3) * anchor_vec[i]
|
pwh = torch.exp(ps[:, 2:4]).clamp(max=1E3) * anchor_vec[i]
|
||||||
pbox = torch.cat((pxy, pwh), 1) # predicted box
|
pbox = torch.cat((pxy, pwh), 1) # predicted box
|
||||||
giou = 1.0 - bbox_iou(pbox.t(), tbox[i], x1y1x2y2=False, GIoU=True) # giou computation
|
giou = bbox_iou(pbox.t(), tbox[i], x1y1x2y2=False, GIoU=True) # giou computation
|
||||||
lbox += giou.sum() if red == 'sum' else giou.mean() # giou loss
|
lbox += (1.0 - giou).sum() if red == 'sum' else (1.0 - giou).mean() # giou loss
|
||||||
|
tobj[b, a, gj, gi] = 1.0 # giou.type(tobj.dtype) # obj
|
||||||
|
|
||||||
if 'default' in arc and model.nc > 1: # cls loss (only if multiple classes)
|
if 'default' in arc and model.nc > 1: # cls loss (only if multiple classes)
|
||||||
t = torch.zeros_like(ps[:, 5:]) # targets
|
t = torch.zeros_like(ps[:, 5:]) # targets
|
||||||
|
|
Loading…
Reference in New Issue