in criterion.py [0:0]
def single_output_forward(self, outputs, targets):
gious = generalized_box3d_iou(
outputs["box_corners"],
targets["gt_box_corners"],
targets["nactual_gt"],
rotated_boxes=torch.any(targets["gt_box_angles"] > 0).item(),
needs_grad=(self.loss_weight_dict["loss_giou_weight"] > 0),
)
outputs["gious"] = gious
center_dist = torch.cdist(
outputs["center_normalized"], targets["gt_box_centers_normalized"], p=1
)
outputs["center_dist"] = center_dist
assignments = self.matcher(outputs, targets)
losses = {}
for k in self.loss_functions:
loss_wt_key = k + "_weight"
if (
loss_wt_key in self.loss_weight_dict
and self.loss_weight_dict[loss_wt_key] > 0
) or loss_wt_key not in self.loss_weight_dict:
# only compute losses with loss_wt > 0
# certain losses like cardinality are only logged and have no loss weight
curr_loss = self.loss_functions[k](outputs, targets, assignments)
losses.update(curr_loss)
final_loss = 0
for k in self.loss_weight_dict:
if self.loss_weight_dict[k] > 0:
losses[k.replace("_weight", "")] *= self.loss_weight_dict[k]
final_loss += losses[k.replace("_weight", "")]
return final_loss, losses