updates
This commit is contained in:
parent
b8b89a3132
commit
1dc1761f45
2
train.py
2
train.py
|
@ -211,7 +211,7 @@ def train():
|
||||||
print('Starting training for %g epochs...' % epochs)
|
print('Starting training for %g epochs...' % epochs)
|
||||||
for epoch in range(start_epoch, epochs): # epoch ------------------------------------------------------------------
|
for epoch in range(start_epoch, epochs): # epoch ------------------------------------------------------------------
|
||||||
model.train()
|
model.train()
|
||||||
model.hyp['gr'] = 1 - (1 + math.cos(min(epoch * 2, epochs) * math.pi / epochs)) / 2 # GIoU <-> 1.0 loss ratio
|
model.gr = 1 - (1 + math.cos(min(epoch * 2, epochs) * math.pi / epochs)) / 2 # GIoU <-> 1.0 loss ratio
|
||||||
|
|
||||||
# Prebias
|
# Prebias
|
||||||
if prebias:
|
if prebias:
|
||||||
|
|
|
@ -401,7 +401,7 @@ def compute_loss(p, targets, model): # predictions, targets, model
|
||||||
pbox = torch.cat((pxy, pwh), 1) # predicted box
|
pbox = torch.cat((pxy, pwh), 1) # predicted box
|
||||||
giou = 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 += (1.0 - giou).sum() if red == 'sum' else (1.0 - 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 - h['gr']) + h['gr'] * giou.detach().clamp(0).type(tobj.dtype) # giou ratio
|
tobj[b, a, gj, gi] = (1.0 - model.gr) + model.gr * giou.detach().clamp(0).type(tobj.dtype) # giou ratio
|
||||||
|
|
||||||
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