当前位置:网站首页>Boost the rising point | yolov5 combined with alpha IOU
Boost the rising point | yolov5 combined with alpha IOU
2022-06-28 06:19:00 【Caribbean kelp 66】
Thesis title :《Alpha-IoU: A Family of Power Intersection over Union Losses for Bounding Box Regression》
Address of thesis : https://arxiv.org/abs/2110.13675v2

1. Brief introduction of the paper :
In this paper, , The author bases the existing on IoU Loss To a new Power IoU series Loss, The series has a Power IoU Item and an additional Power The regularization , Have a single Power Parameters α. Call this new loss series α-IoU Loss. Experiments on multi-target detection benchmarks and models show that ,α-IoU Loss :
It can significantly exceed the existing IoU The loss of ;
By adjusting the α, Enable the detector to achieve different levels of bbox Greater flexibility in regression accuracy ;
It is more robust to small data sets and noise .
Experimental results show that ,α(α>1) Added high IoU Target loss and gradient , And then improve bbox Regression accuracy .
power Parameters α It can be used as an adjustment α-IoU Loss of superparameters to meet different levels of bbox Regression accuracy , among α >1 By paying more attention to High IoU Objective to obtain high regression accuracy ( namely High IoU threshold ).
α Not overly sensitive to different models or data sets , in the majority of cases ,α=3 Always perform well .α-IoU The loss family can be easily used to improve the effect of the detector , In a clean or noisy environment , No additional parameters will be introduced , No more training / Reasoning time .
2. Corresponding code :
def bbox_alpha_iou(box1, box2, x1y1x2y2=False, GIoU=False, DIoU=False, CIoU=False, EIoU=False, alpha=3, eps=1e-9):
# Returns tsqrt_he IoU of box1 to box2. box1 is 4, box2 is nx4
box2 = box2.T
# Get the coordinates of bounding boxes
if x1y1x2y2: # x1, y1, x2, y2 = box1
b1_x1, b1_y1, b1_x2, b1_y2 = box1[0], box1[1], box1[2], box1[3]
b2_x1, b2_y1, b2_x2, b2_y2 = box2[0], box2[1], box2[2], box2[3]
else: # transform from xywh to xyxy
b1_x1, b1_x2 = box1[0] - box1[2] / 2, box1[0] + box1[2] / 2
b1_y1, b1_y2 = box1[1] - box1[3] / 2, box1[1] + box1[3] / 2
b2_x1, b2_x2 = box2[0] - box2[2] / 2, box2[0] + box2[2] / 2
b2_y1, b2_y2 = box2[1] - box2[3] / 2, box2[1] + box2[3] / 2
# Intersection area
inter = (torch.min(b1_x2, b2_x2) - torch.max(b1_x1, b2_x1)).clamp(0) * \
(torch.min(b1_y2, b2_y2) - torch.max(b1_y1, b2_y1)).clamp(0)
# Union Area
w1, h1 = b1_x2 - b1_x1, b1_y2 - b1_y1 + eps
w2, h2 = b2_x2 - b2_x1, b2_y2 - b2_y1 + eps
union = w1 * h1 + w2 * h2 - inter + eps
# change iou into pow(iou+eps) Join in α The next power
# alpha iou
iou = torch.pow(inter / union + eps, alpha)
beta = 2 * alpha
if GIoU or DIoU or CIoU or EIoU:
# The minimum closure region of two boxes width and height
cw = torch.max(b1_x2, b2_x2) - torch.min(b1_x1, b2_x1) # convex (smallest enclosing box) width
ch = torch.max(b1_y2, b2_y2) - torch.min(b1_y1, b2_y1) # convex height
if CIoU or DIoU or EIoU: # Distance or Complete IoU https://arxiv.org/abs/1911.08287v1
# Minimum circumscribed rectangle The length of the diagonal is squared
c2 = cw ** beta + ch ** beta + eps # convex diagonal
rho_x = torch.abs(b2_x1 + b2_x2 - b1_x1 - b1_x2)
rho_y = torch.abs(b2_y1 + b2_y2 - b1_y1 - b1_y2)
# The square of the distance between the center points of two frames
rho2 = (rho_x ** beta + rho_y ** beta) / (2 ** beta) # center distance
if DIoU:
return iou - rho2 / c2 # DIoU
elif CIoU: # https://github.com/Zzh-tju/DIoU-SSD-pytorch/blob/master/utils/box/box_utils.py#L47
v = (4 / math.pi ** 2) * torch.pow(torch.atan(w2 / h2) - torch.atan(w1 / h1), 2)
with torch.no_grad():
alpha_ciou = v / ((1 + eps) - inter / union + v)
# return iou - (rho2 / c2 + v * alpha_ciou) # CIoU
return iou - (rho2 / c2 + torch.pow(v * alpha_ciou + eps, alpha)) # CIoU
# EIoU stay CIoU On the basis of
# The aspect ratio loss term of the predicted frame width and height The difference between the width and height of the split prediction frame and the width and height of the minimum external frame
# It accelerates the convergence and improves the regression accuracy
elif EIoU:
rho_w2 = ((b2_x2 - b2_x1) - (b1_x2 - b1_x1)) ** beta
rho_h2 = ((b2_y2 - b2_y1) - (b1_y2 - b1_y1)) ** beta
cw2 = cw ** beta + eps
ch2 = ch ** beta + eps
return iou - (rho2 / c2 + rho_w2 / cw2 + rho_h2 / ch2)
# GIoU https://arxiv.org/pdf/1902.09630.pdf
c_area = torch.max(cw * ch + eps, union) # convex area
return iou - torch.pow((c_area - union) / c_area + eps, alpha) # GIoU
else:
return iou # torch.log(iou+eps) or iou
Last , take utils/loss.py In the document iou=bbox_iou Switch to iou=bbox_alpha_iou that will do .
边栏推荐
- idea创建类时自动添加注释
- death_ satan/hyperf-validate
- PKG package node project (express)
- 5-minute NLP: summary of time chronology from bag of words to transformer
- JSP
- At first glance, I can see several methods used by motionlayout
- Configure multiple database connections using the SSM framework
- socke.io長連接實現推送、版本控制、實時活躍用戶量統計
- Yolact++ pytoch environment
- 使用SQL select count distinct查询语句统计数据库中某个字段的唯一值总数量
猜你喜欢

Sklearn Feature Engineering (summary)

Linux Mysql 实现root用户不用密码登录

Uni app wechat applet sharing function

How to add live chat in your Shopify store?

基于Kotlin+JetPack实现的MVVM框架的示例

AutoCAD C polyline small acute angle detection

How the third-party libraries in cocoapod reference local header files
![[staff] arpeggio mark](/img/45/0ee0089b947b467344b247839893d7.jpg)
[staff] arpeggio mark

Error reporting - resolve core JS / modules / es error. cause. JS error

CAD二次开发+NetTopologySuite+PGIS 引用多版本DLL问题
随机推荐
@Autowired注解为空的原因
Configure multiple database connections using the SSM framework
PKG package node project (express)
[staff] arpeggio mark
Introduction to browser tools: think sky browser, team work browser
Paper recommendation: efficientnetv2 - get smaller models and faster training speed through NAS, scaling and fused mbconv
不会还有人只会用forEach遍历数组吧?
MySQL (II) - basic operation
Lombok @equalsandhashcode annotation how to make objects The equals () method compares only some attributes
Oracle condition, circular statement
AttributeError: 'callable_ iterator' object has no attribute 'next'
Uni app wechat applet sharing function
脚本语言和编程语言
MySQL (I) - Installation
socke.io長連接實現推送、版本控制、實時活躍用戶量統計
重载,重写的区别,抽象类,接口的区别
Mosaic data enhanced mosaic
easyui下拉框选中触发事件
报错--解决core-js/modules/es.error.cause.js报错
ROS rviz_satellite功能包可视化GNSS轨迹,卫星地图的使用