当前位置:网站首页>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 .
边栏推荐
- socke.io長連接實現推送、版本控制、實時活躍用戶量統計
- JSP
- 基本类型和包装类的区别
- 借助nz-pagination中的let-total解析ng-template
- MySQL (II) - basic operation
- How to add live chat in your Shopify store?
- ImportError: cannot import name 'ensure_dir_exists'的可解决办法
- YYGH-7-用户管理
- MR-WordCount
- 5-minute NLP: summary of time chronology from bag of words to transformer
猜你喜欢
How to add live chat in your Shopify store?
YYGH-BUG-02
Introduction to browser tools: think sky browser, team work browser
D3D11_ Chili_ Tutorial (3): design a bindable/drawable system
Error reporting - resolve core JS / modules / es error. cause. JS error
Example of MVVM framework based on kotlin+jetpack
cocoapod中的第三方库怎么引用本地头文件
AutoCAD C # Polyline Small Sharp angle Detection
AutoCAD C polyline self intersection detection
FPGA - 7系列 FPGA SelectIO -09- 高级逻辑资源之IO_FIFO
随机推荐
FPGA - 7系列 FPGA SelectIO -07- 高级逻辑资源之ISERDESE2
Lombok @equalsandhashcode annotation how to make objects The equals () method compares only some attributes
ThreadLocal
AutoCAD C polyline self intersection detection
Xcode13.3.1 error reported after pod install
Use of JDBC
API learning of OpenGL (2007) gltexcoordpointer
Exception handling (I) -- null pointer and array index out of bounds
Note that JPA uses a custom VO to receive jpql query results
socke. IO long connection enables push, version control, and real-time active user statistics
移动广告发展动向:撬动存量,精细营销
手把手教你用Ucos
Object对象转 List集合
easyui 重置多条件查询
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance
ROS rviz_satellite功能包可视化GNSS轨迹,卫星地图的使用
MySQL(一)——安装
mac下安装多个版本php并且进行管理
cocoapod中的第三方库怎么引用本地头文件
PKG package node project (express)