Skip to content

Commit

Permalink
I found Objectness in ComputeLoss which might need improvement (ultra…
Browse files Browse the repository at this point in the history
  • Loading branch information
XHBrain committed Jun 14, 2021
1 parent 239a11c commit 18a8eec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion utils/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ def __call__(self, p, targets): # predictions, targets, model
lbox += (1.0 - iou).mean() # iou loss

# Objectness
tobj[b, a, gj, gi] = (1.0 - self.gr) + self.gr * iou.detach().clamp(0).type(tobj.dtype) # iou ratio
score_iou = iou.detach().clamp(0).type(tobj.dtype)
sort_id = torch.argsort(score_iou)
b, a, gj, gi, score_iou = b[sort_id], a[sort_id], gj[sort_id], gi[sort_id], score_iou[sort_id]
tobj[b, a, gj, gi] = (1.0 - self.gr) + self.gr * score_iou # iou ratio

# Classification
if self.nc > 1: # cls loss (only if multiple classes)
Expand Down

0 comments on commit 18a8eec

Please sign in to comment.