realize boxcoder's encoding

This commit is contained in:
Francis Lata
2025-01-19 15:59:28 -08:00
parent bf0cce7945
commit bef389dec7

View File

@@ -176,7 +176,7 @@ class RegressionHead:
def _compute_loss(self, x:Tensor, bboxes:Tensor, matches:Tensor, anchors:Tensor) -> Tensor:
mask = (fg_idxs := matches >= 0).reshape(matches.shape[0], -1, 1)
tgt = self.box_coder.encode(bboxes, anchors)
tgt = self.box_coder.encode(bboxes, anchors).realize()
loss = mask.where(l1_loss(x, tgt), 0).sum(-1).sum(-1)
loss = (loss / fg_idxs.sum(-1)).sum() / matches.shape[0]
return loss