parameters: (self, outputs, targets, indices, num_boxes)
return_statement: return losses
docstring: 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, h, w), normalized by the image size.
docstring_summary: 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, h, w), normalized by the image size.
docstring_tokens: 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 h w ) normalized by the image size .
function: 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, h, w), normalized by the image size.
          """
          assert 'pred_boxes' in outputs
          idx = self._get_src_permutation_idx(indices)
          src_boxes = outputs['pred_boxes'][idx]
          target_boxes = torch.cat([t['boxes'][i] for t, (_, i) in zip(targets, indices)], dim=0)
  
          loss_bbox = F.l1_loss(src_boxes, target_boxes, reduction='none')
  
          losses = {}
          losses['loss_bbox'] = loss_bbox.sum() / num_boxes
  
          loss_giou = 1 - torch.diag(generalized_box_iou(
              box_cxcywh_to_xyxy(src_boxes),
              box_cxcywh_to_xyxy(target_boxes)))
          losses['loss_giou'] = loss_giou.sum() / num_boxes
          return losses
function_tokens: def loss_boxes ( self , outputs , targets , indices , num_boxes ) : assert 'pred_boxes' in outputs idx = self . _get_src_permutation_idx ( indices ) src_boxes = outputs [ 'pred_boxes' ] [ idx ] target_boxes = torch . cat ( [ t [ 'boxes' ] [ i ] for t , ( _ , i ) in zip ( targets , indices ) ] , dim = 0 ) loss_bbox = F . l1_loss ( src_boxes , target_boxes , reduction = 'none' ) losses = { } losses [ 'loss_bbox' ] = loss_bbox . sum ( ) / num_boxes loss_giou = 1 - torch . diag ( generalized_box_iou ( box_cxcywh_to_xyxy ( src_boxes ) , box_cxcywh_to_xyxy ( target_boxes ) ) ) losses [ 'loss_giou' ] = loss_giou . sum ( ) / num_boxes return losses