Shortcuts

distance_box_iou_loss

torchvision.ops.distance_box_iou_loss(boxes1: torch.Tensor, boxes2: torch.Tensor, reduction: str = 'none', eps: float = 1e-07)torch.Tensor[source]

Gradient-friendly IoU loss with an additional penalty that is non-zero when the distance between boxes’ centers isn’t zero. Indeed, for two exactly overlapping boxes, the distance IoU is the same as the IoU loss. This loss is symmetric, so the boxes1 and boxes2 arguments are interchangeable.

Both sets of boxes are expected to be in (x1, y1, x2, y2) format with 0 <= x1 < x2 and 0 <= y1 < y2, and The two boxes should have the same dimensions.

Parameters
  • boxes1 (Tensor[N, 4]) – first set of boxes

  • boxes2 (Tensor[N, 4]) – second set of boxes

  • reduction (string, optional) – Specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'. 'none': No reduction will be applied to the output. 'mean': The output will be averaged. 'sum': The output will be summed. Default: 'none'

  • eps (float, optional) – small number to prevent division by zero. Default: 1e-7

Returns

Loss tensor with the reduction option applied.

Return type

Tensor

Reference:

Zhaohui Zheng et. al: Distance Intersection over Union Loss: https://arxiv.org/abs/1911.08287

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources