当前位置:网站首页>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 .
边栏推荐
- Xcode13.3.1 error reported after pod install
- easyui 重置多条件查询
- AttributeError: 'callable_ iterator' object has no attribute 'next'
- Caused by: com. fasterxml. jackson. databind. exc.InvalidDefinitionException: Cannot construct instance
- ES9023音频解码芯片的工作原理
- lombok @EqualsAndHashCode 注解如何让对象.equals()方法只比较部分属性
- Linux Mysql 实现root用户不用密码登录
- Configure multiple database connections using the SSM framework
- The custom cube UI pop-up dialog supports multiple and multiple types of input boxes
- 4. use MySQL shell to install and deploy Mgr clusters | explain Mgr in simple terms
猜你喜欢

Linked list (III) - reverse linked list

YYGH-BUG-03

YYGH-7-用户管理

What are the advantages of e-mail marketing? Why do sellers of shopline independent station attach so much importance to it?

Independent station sellers are using the five e-mail marketing skills, do you know?

YYGH-BUG-03

How popular are FB and WhatsApp mass messages in 2022?

Sklearn Feature Engineering (summary)

Caused by: com. fasterxml. jackson. databind. exc.InvalidDefinitionException: Cannot construct instance

lombok @EqualsAndHashCode 注解如何让对象.equals()方法只比较部分属性
随机推荐
Caused by: com. fasterxml. jackson. databind. exc.InvalidDefinitionException: Cannot construct instance
High quality domestic stereo codec cjc8988, pin to pin replaces wm8988
链表(三)——反转链表
FPGA - 7系列 FPGA SelectIO -09- 高级逻辑资源之IO_FIFO
手把手教你用Ucos
简单手写debounce函数
ImportError: cannot import name 'ensure_ dir_ Possible solutions for exists'
Simple handwritten debounce function
JSP
API learning of OpenGL (2006) glclientactivetexture
mac下安装多个版本php并且进行管理
JQ picture amplifier
Using pytorch and tensorflow to calculate the confusion matrix of classification model
Uni app wechat applet sharing function
CAD二次开发+NetTopologySuite+PGIS 引用多版本DLL问题
MySQL(一)——安装
YYGH-6-微信登录
Valueerror: iterative over raw text documents expected, string object received
sql及list去重操作
[untitled]