parameters: (self, preds, bbox, eps=1e-7, reduction='mean')
return_statement: return loss
docstring: :param preds:[[x1,y1,x2,y2], [x1,y1,x2,y2],,,]
          :param bbox:[[x1,y1,x2,y2], [x1,y1,x2,y2],,,]
          :return: loss
docstring_summary: :param preds:[[x1,y1,x2,y2], [x1,y1,x2,y2],,,]
          :param bbox:[[x1,y1,x2,y2], [x1,y1,x2,y2],,,]
          :return: loss
docstring_tokens: : param preds : [[ x1 y1 x2 y2 ] [ x1 y1 x2 y2 ] ] : param bbox : [[ x1 y1 x2 y2 ] [ x1 y1 x2 y2 ] ] : return : loss
function: def giou_loss(self, preds, bbox, eps=1e-7, reduction='mean'):
          '''
          :param preds:[[x1,y1,x2,y2], [x1,y1,x2,y2],,,]
          :param bbox:[[x1,y1,x2,y2], [x1,y1,x2,y2],,,]
          :return: loss
          '''
          ix1 = fluid.layers.elementwise_max(preds[:, 0], bbox[:, 0])
          iy1 = fluid.layers.elementwise_max(preds[:, 1], bbox[:, 1])
          ix2 = fluid.layers.elementwise_min(preds[:, 2], bbox[:, 2])
          iy2 = fluid.layers.elementwise_min(preds[:, 3], bbox[:, 3])
  
          iw = fluid.layers.clip(ix2 - ix1 + 1e-3, 0., 1e10)
          ih = fluid.layers.clip(iy2 - iy1 + 1e-3, 0., 1e10)
  
          # overlap
          inters = iw * ih
  
          # union
          uni = (preds[:, 2] - preds[:, 0] + 1e-3) * (preds[:, 3] - preds[:, 1] + 1e-3
              ) + (bbox[:, 2] - bbox[:, 0] + 1e-3) * (
              bbox[:, 3] - bbox[:, 1] + 1e-3) - inters + eps
  
          # ious
          ious = inters / uni
  
          ex1 = fluid.layers.elementwise_min(preds[:, 0], bbox[:, 0])
          ey1 = fluid.layers.elementwise_min(preds[:, 1], bbox[:, 1])
          ex2 = fluid.layers.elementwise_max(preds[:, 2], bbox[:, 2])
          ey2 = fluid.layers.elementwise_max(preds[:, 3], bbox[:, 3])
          ew = fluid.layers.clip(ex2 - ex1 + 1e-3, 0., 1e10)
          eh = fluid.layers.clip(ey2 - ey1 + 1e-3, 0., 1e10)
  
          # enclose erea
          enclose = ew * eh + eps
          giou = ious - (enclose - uni) / enclose
  
          loss = 1 - giou
  
          if reduction == 'mean':
              loss = paddle.mean(loss)
          elif reduction == 'sum':
              loss = paddle.sum(loss)
          else:
              raise NotImplementedError
          return loss
function_tokens: def giou_loss ( self , preds , bbox , eps = 1e-7 , reduction = 'mean' ) : ix1 = fluid . layers . elementwise_max ( preds [ : , 0 ] , bbox [ : , 0 ] ) iy1 = fluid . layers . elementwise_max ( preds [ : , 1 ] , bbox [ : , 1 ] ) ix2 = fluid . layers . elementwise_min ( preds [ : , 2 ] , bbox [ : , 2 ] ) iy2 = fluid . layers . elementwise_min ( preds [ : , 3 ] , bbox [ : , 3 ] ) iw = fluid . layers . clip ( ix2 - ix1 + 1e-3 , 0. , 1e10 ) ih = fluid . layers . clip ( iy2 - iy1 + 1e-3 , 0. , 1e10 ) # overlap inters = iw * ih # union uni = ( preds [ : , 2 ] - preds [ : , 0 ] + 1e-3 ) * ( preds [ : , 3 ] - preds [ : , 1 ] + 1e-3 ) + ( bbox [ : , 2 ] - bbox [ : , 0 ] + 1e-3 ) * ( bbox [ : , 3 ] - bbox [ : , 1 ] + 1e-3 ) - inters + eps # ious ious = inters / uni ex1 = fluid . layers . elementwise_min ( preds [ : , 0 ] , bbox [ : , 0 ] ) ey1 = fluid . layers . elementwise_min ( preds [ : , 1 ] , bbox [ : , 1 ] ) ex2 = fluid . layers . elementwise_max ( preds [ : , 2 ] , bbox [ : , 2 ] ) ey2 = fluid . layers . elementwise_max ( preds [ : , 3 ] , bbox [ : , 3 ] ) ew = fluid . layers . clip ( ex2 - ex1 + 1e-3 , 0. , 1e10 ) eh = fluid . layers . clip ( ey2 - ey1 + 1e-3 , 0. , 1e10 ) # enclose erea enclose = ew * eh + eps giou = ious - ( enclose - uni ) / enclose loss = 1 - giou if reduction == 'mean' : loss = paddle . mean ( loss ) elif reduction == 'sum' : loss = paddle . sum ( loss ) else : raise NotImplementedError return loss