目标检测中IoU(Intersection over Union)的概念理解

参考博客

深度学习中IU、IoU(Intersection over Union)的概念理解以及python程序实现

一、IoU(交并比)概念

目标检测中IoU(Intersection over Union)的概念理解_第1张图片

Intersection over Union,是一种测量在特定数据集中检测相应物体准确度的一个标准,这个标准用于测量真实和预测之间的相关度,相关度越高,该值越高。

IoU相当于两个区域重叠的部分除以两个区域的集合部分得出的结果。
一般来说,这个score > 0.5 就可以被认为一个不错的结果了。

目标检测中IoU(Intersection over Union)的概念理解_第2张图片 标题

二、物体检测中的IoU

目标检测中IoU(Intersection over Union)的概念理解_第3张图片

绿色标线是人为标记的正确结果,红色标线是算法预测出来的结果,IoU要做的就是在这两个结果中测量算法的准确度

三、python程序实现IoU

def bb_intersection_over_union(boxA, boxB):
	# determine the (x, y)-coordinates of the intersection rectangle
	xA = max(boxA[0], boxB[0])
	yA = max(boxA[1], boxB[1])
	xB = min(boxA[2], boxB[2])
	yB = min(boxA[3], boxB[3])
 
	# compute the area of intersection rectangle
	interArea = (xB - xA + 1) * (yB - yA + 1)
 
	# compute the area of both the prediction and ground-truth
	# rectangles
	boxAArea = (boxA[2] - boxA[0] + 1) * (boxA[3] - boxA[1] + 1)
	boxBArea = (boxB[2] - boxB[0] + 1) * (boxB[3] - boxB[1] + 1)
 
	# compute the intersection over union by taking the intersection
	# area and dividing it by the sum of prediction + ground-truth
	# areas - the interesection area
	iou = interArea / float(boxAArea + boxBArea - interArea)
 
	# return the intersection over union value
	return iou

你可能感兴趣的:(深度学习,IoU,目标检测)