loss/set_criterion.py
def loss_boxes(self, outputs, targets, indices, num_boxes):
        """Compute the losses related to the bounding boxes, the L1 regression loss and the GIoU loss
           targets dicts must contain the key "boxes" containing a tensor of dim [nb_target_boxes, 4]
           The target boxes are expected in format (center_x, center_y, w, h), normalized by the image size.
        """
        assert 'human_pred_boxes' in outputs
        assert 'object_pred_boxes' in outputs
        # indice: calculated by minimum match loss which use matcher to calculate
        idx = self._get_src_permutation_idx(indices)

        human_src_boxes = outputs['human_pred_boxes'][idx]
        human_target_boxes = torch.cat(
            [t['human_boxes'][i] for t, (_, i) in zip(targets, indices)], dim=0)
        object_src_boxes = outputs['object_pred_boxes'][idx]
        object_target_boxes = torch.cat(
            [t['object_boxes'][i] for t, (_, i) in zip(targets, indices)], dim=0)

        human_loss_bbox = F.l1_loss(
            human_src_boxes, human_target_boxes, reduction='none')
        object_loss_bbox = F.l1_loss(
            object_src_boxes, object_target_boxes, reduction='none')

        losses = dict()
        losses['human_loss_bbox'] = human_loss_bbox.sum() / num_boxes
        losses['object_loss_bbox'] = object_loss_bbox.sum() / num_boxes
        losses['loss_bbox'] = losses['human_loss_bbox'] + \
            losses['object_loss_bbox']

        human_loss_giou = 1 - torch.diag(box_ops.generalized_box_iou(
            box_ops.box_cxcywh_to_xyxy(human_src_boxes),
            box_ops.box_cxcywh_to_xyxy(human_target_boxes)))
        object_loss_giou = 1 - torch.diag(box_ops.generalized_box_iou(
            box_ops.box_cxcywh_to_xyxy(object_src_boxes),
            box_ops.box_cxcywh_to_xyxy(object_target_boxes)))
        losses['human_loss_giou'] = human_loss_giou.sum() / num_boxes
        losses['object_loss_giou'] = object_loss_giou.sum() / num_boxes

        losses['loss_giou'] = losses['human_loss_giou'] + \
            losses['object_loss_giou']
        return losses
Compute the losses related to the bounding boxes, the L1 regression loss and the GIoU loss
           targets dicts must contain the key "boxes" containing a tensor of dim [nb_target_boxes, 4]
           The target boxes are expected in format (center_x, center_y, w, h), normalized by the image size.
        
Compute the losses related to the bounding boxes, the L1 regression loss and the GIoU loss
targets dicts must contain the key "boxes" containing a tensor of dim [nb_target_boxes, 4]
The target boxes are expected in format (center_x, center_y, w, h), normalized by the image size.
Compute the losses related to the bounding boxes the L1 regression loss and the GIoU loss targets dicts must contain the key " boxes " containing a tensor of dim [ nb_target_boxes 4 ] The target boxes are expected in format ( center_x center_y w h ) normalized by the image size .
def loss_boxes(self, outputs, targets, indices, num_boxes):
        assert 'human_pred_boxes' in outputs
        assert 'object_pred_boxes' in outputs
        idx = self._get_src_permutation_idx(indices)
        human_src_boxes = outputs['human_pred_boxes'][idx]
        human_target_boxes = torch.cat(
            [t['human_boxes'][i] for t, (_, i) in zip(targets, indices)], dim=0)
        object_src_boxes = outputs['object_pred_boxes'][idx]
        object_target_boxes = torch.cat(
            [t['object_boxes'][i] for t, (_, i) in zip(targets, indices)], dim=0)
        human_loss_bbox = F.l1_loss(
            human_src_boxes, human_target_boxes, reduction='none')
        object_loss_bbox = F.l1_loss(
            object_src_boxes, object_target_boxes, reduction='none')
        losses = dict()
        losses['human_loss_bbox'] = human_loss_bbox.sum() / num_boxes
        losses['object_loss_bbox'] = object_loss_bbox.sum() / num_boxes
        losses['loss_bbox'] = losses['human_loss_bbox'] + \
            losses['object_loss_bbox']
        human_loss_giou = 1 - torch.diag(box_ops.generalized_box_iou(
            box_ops.box_cxcywh_to_xyxy(human_src_boxes),
            box_ops.box_cxcywh_to_xyxy(human_target_boxes)))
        object_loss_giou = 1 - torch.diag(box_ops.generalized_box_iou(
            box_ops.box_cxcywh_to_xyxy(object_src_boxes),
            box_ops.box_cxcywh_to_xyxy(object_target_boxes)))
        losses['human_loss_giou'] = human_loss_giou.sum() / num_boxes
        losses['object_loss_giou'] = object_loss_giou.sum() / num_boxes
        losses['loss_giou'] = losses['human_loss_giou'] + \
            losses['object_loss_giou']
        return losses
def loss_boxes ( self , outputs , targets , indices , num_boxes ) : assert 'human_pred_boxes' in outputs assert 'object_pred_boxes' in outputs idx = self . _get_src_permutation_idx ( indices ) human_src_boxes = outputs [ 'human_pred_boxes' ] [ idx ] human_target_boxes = torch . cat ( [ t [ 'human_boxes' ] [ i ] for t , ( _ , i ) in zip ( targets , indices ) ] , dim = 0 ) object_src_boxes = outputs [ 'object_pred_boxes' ] [ idx ] object_target_boxes = torch . cat ( [ t [ 'object_boxes' ] [ i ] for t , ( _ , i ) in zip ( targets , indices ) ] , dim = 0 ) human_loss_bbox = F . l1_loss ( human_src_boxes , human_target_boxes , reduction = 'none' ) object_loss_bbox = F . l1_loss ( object_src_boxes , object_target_boxes , reduction = 'none' ) losses = dict ( ) losses [ 'human_loss_bbox' ] = human_loss_bbox . sum ( ) / num_boxes losses [ 'object_loss_bbox' ] = object_loss_bbox . sum ( ) / num_boxes losses [ 'loss_bbox' ] = losses [ 'human_loss_bbox' ] + losses [ 'object_loss_bbox' ] human_loss_giou = 1 - torch . diag ( box_ops . generalized_box_iou ( box_ops . box_cxcywh_to_xyxy ( human_src_boxes ) , box_ops . box_cxcywh_to_xyxy ( human_target_boxes ) ) ) object_loss_giou = 1 - torch . diag ( box_ops . generalized_box_iou ( box_ops . box_cxcywh_to_xyxy ( object_src_boxes ) , box_ops . box_cxcywh_to_xyxy ( object_target_boxes ) ) ) losses [ 'human_loss_giou' ] = human_loss_giou . sum ( ) / num_boxes losses [ 'object_loss_giou' ] = object_loss_giou . sum ( ) / num_boxes losses [ 'loss_giou' ] = losses [ 'human_loss_giou' ] + losses [ 'object_loss_giou' ] return losses
Compute the losses related to the bounding boxes, the L1 regression loss and the GIoU loss
targets dicts must contain the key "boxes" containing a tensor of dim [nb_target_boxes, 4]
The target boxes are expected in format (center_x, center_y, w, h), normalized by the image size.
Compute the losses related to the bounding boxes the L1 regression loss and the GIoU loss targets dicts must contain the key " boxes " containing a tensor of dim [ nb_target_boxes 4 ] The target boxes are expected in format ( center_x center_y w h ) normalized by the image size .
"""Compute the losses related to the bounding boxes, the L1 regression loss and the GIoU loss
           targets dicts must contain the key "boxes" containing a tensor of dim [nb_target_boxes, 4]
           The target boxes are expected in format (center_x, center_y, w, h), normalized by the image size.
        """ # indice: calculated by minimum match loss which use matcher to calculate

self
outputs
targets
indices
num_boxes