当前位置:   article > 正文

[修改记录]在yolov5网络的general.py文件中增加EIOU损失函数_eciou yolo

eciou yolo

yolov5中使用的CiOU loss考虑了边界框回归的重叠面积、中心点距离、横纵比。但是ciou loss的公式中v反映的是横纵比的差异,而不是宽高分别与其置信度的真实差异。EIOU loss是在ciou loss的基础上提出的,加入了Focal聚焦优质的锚框。该方法最开始出自于2021年的一篇论文。

《Focal and Efficient IOU Loss for Accurate Bounding Box Regression》

地址:https://arxiv.org/abs/2101.08158

代码修改部分:

修改的主要地方是general.py文件中的bbox_iou函数,修改前的代码如下:

  1. def bbox_iou(box1, box2, x1y1x2y2=True, GIoU=False, DIoU=False, CIoU=False, eps=1e-7):
  2. # Returns the IoU of box1 to box2. box1 is 4, box2 is nx4
  3. box2 = box2.T
  4. # Get the coordinates of bounding boxes
  5. if x1y1x2y2: # x1, y1, x2, y2 = box1
  6. b1_x1, b1_y1, b1_x2, b1_y2 = box1[0], box1[1], box1[2], box1[3]
  7. b2_x1, b2_y1, b2_x2, b2_y2 = box2[0], box2[1], box2[2], box2[3]
  8. else: # transform from xywh to xyxy
  9. b1_x1, b1_x2 = box1[0] - box1[2] / 2, box1[0] + box1[2] / 2
  10. b1_y1, b1_y2 
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号