o  i @sTddlmZddlZddlmZddlmZmZddlm Z GdddeZ e Z dS)) annotationsN)_Loss) COMPUTE_DTYPE box_pair_giou) LossReductioncs2eZdZdZejfd fdd Zdd d ZZS) BoxGIoULossa\ Compute the generalized intersection over union (GIoU) loss of a pair of boxes. The two inputs should have the same shape. giou_loss = 1.0 - giou The range of GIoU is (-1.0, 1.0]. Thus the range of GIoU loss is [0.0, 2.0). Args: reduction: {``"none"``, ``"mean"``, ``"sum"``} Specifies the reduction to apply to the output. Defaults to ``"mean"``. - ``"none"``: no reduction will be applied. - ``"mean"``: the sum of the output will be divided by the number of elements in the output. - ``"sum"``: the output will be summed. reductionLossReduction | strreturnNonecstjt|jddS)N)r)super__init__rvalue)selfr __class__X/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/losses/giou_loss.pyr $szBoxGIoULoss.__init__input torch.TensortargetcCs|j|jkrtd|jd|jd|j}t|jtd|jtd}d|}|jtjj kr3| }n|jtj j kr?| }n|jtj j krGn td|jd||S)aN Args: input: predicted bounding boxes, Nx4 or Nx6 torch tensor. The box mode is assumed to be ``StandardMode`` target: GT bounding boxes, Nx4 or Nx6 torch tensor. The box mode is assumed to be ``StandardMode`` Raises: ValueError: When the two inputs have different shape. z"ground truth has different shape (z) from input ())dtypeg?zUnsupported reduction: z0, available options are ["mean", "sum", "none"].)shape ValueErrorrrtorrrMEANrmeanSUMsumNONE)rrr box_dtypegioulossrrrforward's    zBoxGIoULoss.forward)rr r r )rrrrr r) __name__ __module__ __qualname____doc__rrr r$ __classcell__rrrrrsr) __future__rtorchtorch.nn.modules.lossrmonai.data.box_utilsrr monai.utilsrrr"rrrrs   .