本文主要是介绍Object Detection--Loss Function:从IoU到CIoU,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
本篇总结Loss Function中的IoU系列代码。
1. IoU
交并集,两个框交集面积除以并集面积。(论写写画画的重要性)
"""
box1[x1, y1, x2, y2]
box2[x1, y1, x2, y2]
return iou
"""
def iou(box1, box2):# Intersectionw = max(0, min(box1[2], box2[2])-max(box1[0], box2[0]))h = max(0, min(box1[3], box2[3])-max(box1[1], box2[1]))# Unions1 = (box1[2]-box1[0]) * (box1[3]-box1[1])s2 = (box2[2]-box2[0]) * (box2[3]-box2[1])return (w*h)/(s1+s2-w*h)
这篇关于Object Detection--Loss Function:从IoU到CIoU的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!