updates
This commit is contained in:
parent
9953335cfe
commit
321bd95764
|
@ -156,7 +156,8 @@ class YOLOLayer(nn.Module):
|
|||
io[..., :4] *= self.stride
|
||||
|
||||
io[..., 4:] = torch.sigmoid(io[..., 4:]) # p_conf, p_cls
|
||||
# io[..., 5:] = F.softmax(io[..., 5:], dim=4) # p_cls
|
||||
# io[..., 4:] = F.softmax(io[..., 4:], dim=4) # unified detection CE
|
||||
# io[..., 4] = io[..., 5:].max(4)[0] # unified detection BCE
|
||||
|
||||
if self.nc == 1:
|
||||
io[..., 5] = 1 # single-class model https://github.com/ultralytics/yolov3/issues/235
|
||||
|
|
2
train.py
2
train.py
|
@ -37,7 +37,7 @@ except:
|
|||
hyp = {'giou': 1.582, # giou loss gain
|
||||
'xy': 4.688, # xy loss gain
|
||||
'wh': 0.1857, # wh loss gain
|
||||
'cls': 27.76, # cls loss gain (CE should be around ~1.0)
|
||||
'cls': 27.76, # cls loss gain (CE=~1.0, uCE=~20, uBCE=~200,~30)
|
||||
'cls_pw': 1.446, # cls BCELoss positive_weight
|
||||
'obj': 21.35, # obj loss gain
|
||||
'obj_pw': 3.941, # obj BCELoss positive_weight
|
||||
|
|
|
@ -324,6 +324,14 @@ def compute_loss(p, targets, model, giou_loss=True): # predictions, targets, mo
|
|||
lcls += (k * h['cls']) * BCEcls(pi[..., 5:], tclsm) # BCE
|
||||
# lcls += (k * h['cls']) * CE(pi[..., 5:], tcls[i]) # CE
|
||||
|
||||
# udm_ce = torch.zeros_like(pi0[..., 0]).long() # unified detection matrix for CE
|
||||
# udm_ce[b, a, gj, gi] = tcls[i] + 1
|
||||
# lcls += (k * h['cls']) * CE(pi0[..., 4:].view(-1, model.nc + 1), udm_ce.view(-1)) # unified CE
|
||||
|
||||
# udm = torch.zeros_like(pi0[..., 5:]) # unified detection matrix for BCE
|
||||
# udm[b, a, gj, gi, tcls[i]] = 1.0
|
||||
# lcls += (k * h['cls']) * BCEcls(pi0[..., 5:], udm) # unified BCE (hyps 200-30)
|
||||
|
||||
# Append targets to text file
|
||||
# with open('targets.txt', 'a') as file:
|
||||
# [file.write('%11.5g ' * 4 % tuple(x) + '\n') for x in torch.cat((txy[i], twh[i]), 1)]
|
||||
|
|
Loading…
Reference in New Issue