[论文笔记] Generalized Intersection over Union

[论文笔记] Generalized Intersection over Union

论文链接
在这里插入图片描述

一,大纲

​ 包围框回归是2D/3D 视觉任务中一个最基础的模块,不管是目标检测,目标跟踪,还是实例分割,都依赖于对bounding box进行回归,以获得准确的定位效果。目前基于深度学习的方法想获得更好的检测性能,要么是用更好的backbone,要么是设计更好的策略提取更好的feature,然而却忽视了bounding box regression中L1、L2 loss这个可以提升的点。

​ 而在该篇论文中,作者先表明了常用的Ln LOSS没法很好地体现出regression的效果,然后分析了直接使用IOU指标(判断predict box和gt的距离的最直接的指标)作为损失函数的利弊,然后提出了改进指标GIOU并用GIoU loss替换掉了大多数目标检测算法中bounding box regression loss,最后接用实验结果证明了GIOU的优越性。

二,Ln LOSS的不足

​ 首先,IoU是目标检测中最常用的评估尺度,它是一种比值的概念&#x

### 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() ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值