Skip to content

Commit

Permalink
Merge pull request pytorch#2 from o295/main
Browse files Browse the repository at this point in the history
Fixing lint in giou_loss.py
  • Loading branch information
xiaohu2015 authored Nov 19, 2021
2 parents a683060 + 3cf91e3 commit 1f67950
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions torchvision/ops/giou_loss.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
import torch

# copy from https://github.com/facebookresearch/fvcore/blob/main/fvcore/nn/giou_loss.py

def giou_loss(
boxes1: torch.Tensor,
boxes2: torch.Tensor,
reduction: str = "none",
eps: float = 1e-7,
) -> torch.Tensor:
"""
Original implementation from
https://github.com/facebookresearch/fvcore/blob/bfff2ef/fvcore/nn/giou_loss.py
Generalized Intersection over Union Loss (Hamid Rezatofighi et. al)
https://arxiv.org/abs/1902.09630
Gradient-friendly IoU loss with an additional penalty that is non-zero when the
boxes do not overlap and scales with the size of their smallest enclosing box.
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.
Args:
boxes1, boxes2 (Tensor): box locations in XYXY format, shape (N, 4) or (4,).
boxes1 (Tensor[N, 4] or Tensor[4]): first set of boxes
boxes2 (Tensor[N, 4] or Tensor[4]): second set of boxes
reduction: 'none' | 'mean' | 'sum'
'none': No reduction will be applied to the output.
'mean': The output will be averaged.
Expand Down

0 comments on commit 1f67950

Please sign in to comment.