当前位置:网站首页>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 .
边栏推荐
- PKG package node project (express)
- Caused by: com. fasterxml. jackson. databind. exc.InvalidDefinitionException: Cannot construct instance
- 借助nz-pagination中的let-total解析ng-template
- Configure multiple database connections using the SSM framework
- Yygh-6-wechat login
- Taobao seo training video course [22 lectures]
- 【Paper Reading-3D Detection】Fully Convolutional One-Stage 3D Object Detection on LiDAR Range Images
- 创建格式化时间,格式化时区的gson对象。json解析时间格式化 ZonedDateTime
- AutoCAD C# 多段线小锐角检测
- windows上安装redis并永久修改密码,及ssm框架集成redis
猜你喜欢

Development trend of mobile advertising: Leveraging stock and fine marketing

YYGH-6-微信登录

慢内容广告:品牌增长的长线主义

JQ picture amplifier

移动广告发展动向:撬动存量,精细营销

FPGA - 7系列 FPGA SelectIO -08- 高级逻辑资源之OSERDESE2
![Taobao seo training video course [22 lectures]](/img/81/21e844542b35010760d061abe905e9.jpg)
Taobao seo training video course [22 lectures]

链表(二)——设计链表

JDBC learning (I) -- implementing simple CRUD operations

The custom cube UI pop-up dialog supports multiple and multiple types of input boxes
随机推荐
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance
Object object to list collection
Common basic functions of Oracle
Small ball playing
手把手教你用Ucos
移动广告发展动向:撬动存量,精细营销
easyui下拉框选中触发事件
自定义 cube-ui 弹出框dialog支持多个且多种类型的input框
death_ satan/hyperf-validate
SQL and list de duplication
Configure redis from 0
Linked list (III) - reverse linked list
MySQL(二)——基本操作
基于Kotlin+JetPack实现的MVVM框架的示例
Yolact++ pytoch environment
重载,重写的区别,抽象类,接口的区别
Slow content advertising: the long-term principle of brand growth
Using pytorch and tensorflow to calculate the confusion matrix of classification model
ImportError: cannot import name 'ensure_dir_exists'的可解决办法
Oracle condition, circular statement