当前位置:网站首页>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 .
边栏推荐
- Object对象转 List集合
- Mosaic data enhanced mosaic
- 借助nz-pagination中的let-total解析ng-template
- What is the e-commerce conversion rate so abstract?
- Introduction to browser tools: think sky browser, team work browser
- FPGA - 7系列 FPGA SelectIO -08- 高级逻辑资源之OSERDESE2
- Create a gson object that formats the time zone. JSON parsing time formatting zoneddatetime
- JQ picture amplifier
- 慢内容广告:品牌增长的长线主义
- ThreadLocal
猜你喜欢

socke.io长连接实现推送、版本控制、实时活跃用户量统计

How to open UMD, KMD log and dump diagrams in CAMX architecture

Promotion intégrale et ordre des octets de fin de taille

整型提昇和大小端字節序

mac下安装多个版本php并且进行管理

Socket. Io long Connection Push, version Control, Real - Time Active user volume Statistics

MySQL(一)——安装

Ethereum Classic的难度计算|猿创征文

lombok @EqualsAndHashCode 注解如何让对象.equals()方法只比较部分属性

Sharing tips for efficient scripting
随机推荐
AttributeError: 'callable_ iterator' object has no attribute 'next'
简单手写debounce函数
AttributeError: 'callable_iterator' object has no attribute 'next'
Ethereum Classic的难度计算|猿创征文
手把手教你用Ucos
Common basic functions of Oracle
AutoCAD C polyline small acute angle detection
[untitled]
Oracle condition, circular statement
Integer promotion and size side byte order
Lombok @equalsandhashcode annotation how to make objects The equals () method compares only some attributes
链表(二)——设计链表
FPGA - 7系列 FPGA SelectIO -08- 高级逻辑资源之OSERDESE2
cocoapod中的第三方库怎么引用本地头文件
Small ball playing
Global country (and region) information JSON data
Caused by: com. fasterxml. jackson. databind. Exc.invalidformatexception: exception resolution
慢内容广告:品牌增长的长线主义
YYGH-8-预约挂号
Taobao seo training video course [22 lectures]