论文笔记:GIoU

论文《Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression》提出GIoU,它是IoU的改进版,用于解决传统回归损失的尺度不变性问题。GIoU在IoU为0时能提供更多信息,并且是IoU的下界,具有更好的相交情况反应。实验表明GIoU作为损失函数效果更优。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

论文标题:Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression
收录于CVPR 2019

因为整体思想形式比较简单,因此笔记不做赘述。
整体来说本文提出了一个通用的trick,即用GIoU来替换bounding box回归损失函数,而GIoU可看作是对于IoU指标的一个改进。
在作者介绍提出的方法前指出了传统回归损失的缺点:

  • 在相同的L1,L2距离下IoU和GIoU可能会有很大的区别(如下图)(个人以为这一点不太有说服力,因为相同的IoU和GIoU下,L1,L2距离也会有区别)
  • 基于L1,L2距离的loss对于尺度不具有不变性。(这一点倒是挺重要的。YOLO3中对于w,h进行开方处理,就是为了缓解这个问题)
    在这里插入图片描述
    原因如下:
  • 当IOU(A,B)=0时,不能得知A,B互相邻近或者相距较远。
  • IoU不能反映两个物体如何重叠。

比如
在这里插入图片描述

同时IoU仍然有一些优点:

  • IoU可以作为距离,loss=1-IoU。但是当两个物体不相交时无回传梯度。
  • IoU对尺度变化具有不变性,即不受两个物体尺度大小的影响。

因此作者想克服这些缺点同时充分利用优点,因此提出GIoU。
GIoU定义如下:

### Generalized Intersection over Union (GIoU) 论文下载 关于 **Generalized Intersection over Union (GIoU)** 的研究,其原始论文由 Rezatofighi 等人在 2019 年发表,题目为 *Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression*。该论文提出了 GIoU 指标及其损失函数作为边界框回归的一种新方法,解决了传统 IoU 方法无法处理无重叠情况的问题[^3]。 #### 下载链接 以下是论文的官方下载地址: - [PDF Download](https://arxiv.org/pdf/1902.09630.pdf) 此外,斯坦福大学也提供了对该论文的部分解读文档,可以访问以下页面获取更多信息: - 官方解读:[Generalized Intersection over Union (Stanford)](https://cs.stanford.edu/people/rrezab/giou/)[^1] #### 核心概念概述 GIoU 是一种扩展的传统交并比(Intersection over Union, IoU),它通过引入最小闭包的概念来解决两个边界框完全不相交的情况下的优化问题。具体计算方式如下: 设 $A$ 和 $B$ 表示两个边界框,则 GIoU 可表示为: $$ \text{GIoU}(A, B) = \frac{\text{Area of intersection}}{\text{Area of union}} - \frac{\text{Area of } C - (\text{Area of } A \cup B)}{\text{Area of } C} $$ 其中 $C$ 是包围 $A$ 和 $B$ 的最小闭合矩形区域[^5]。 #### 实现代码示例 下面是基于 PyTorch 的简单实现代码片段用于计算 GIoU 损失: ```python import torch def generalized_iou_loss(pred_boxes, target_boxes): """ Calculate the GIoU loss between predicted boxes and ground truth. Args: pred_boxes (Tensor): Predicted bounding boxes with shape (N, 4). target_boxes (Tensor): Ground truth bounding boxes with shape (N, 4). Returns: Tensor: The computed GIoU loss value. """ # Compute areas of anchors and gt boxes area_pred = (pred_boxes[:, 2] - pred_boxes[:, 0]) * (pred_boxes[:, 3] - pred_boxes[:, 1]) area_target = (target_boxes[:, 2] - target_boxes[:, 0]) * (target_boxes[:, 3] - target_boxes[:, 1]) # Find coordinates of intersecting box inter_xmin = torch.max(pred_boxes[:, 0], target_boxes[:, 0]) inter_ymin = torch.max(pred_boxes[:, 1], target_boxes[:, 1]) inter_xmax = torch.min(pred_boxes[:, 2], target_boxes[:, 2]) inter_ymax = torch.min(pred_boxes[:, 3], target_boxes[:, 3]) # Compute overlap width heights w_overlap = torch.clamp(inter_xmax - inter_xmin, min=0) h_overlap = torch.clamp(inter_ymax - inter_ymin, min=0) # Area of overlaps and unions overlap_area = w_overlap * h_overlap union_area = area_pred + area_target - overlap_area # Compute smallest enclosing box C c_xmin = torch.min(pred_boxes[:, 0], target_boxes[:, 0]) c_ymin = torch.min(pred_boxes[:, 1], target_boxes[:, 1]) c_xmax = torch.max(pred_boxes[:, 2], target_boxes[:, 2]) c_ymax = torch.max(pred_boxes[:, 3], target_boxes[:, 3]) c_width = c_xmax - c_xmin c_height = c_ymax - c_ymin closure_area = c_width * c_height iou = overlap_area / union_area giou = iou - ((closure_area - union_area) / closure_area) return 1 - giou.mean() ```
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值