当前位置:网站首页>[IOU] intersection over union
[IOU] intersection over union
2022-06-25 09:12:00 【zbossz】
Used to evaluate the object detection model 
iou The way of calculating is :
Code implementation :
import torch
def intersection_over_union(boxes_preds, boxes_labels, box_format="midpoint"):
global box2_x1, box2_y2, box1_y2, box2_x2, box1_x2, box2_y1, box1_y1, box1_x1
if box_format == "midpoint":
box1_x1 = boxes_preds[..., 0:1] - boxes_preds[..., 2:3] / 2
box1_y1 = boxes_preds[..., 1:2] - boxes_preds[..., 3:4] / 2
box1_x2 = boxes_preds[..., 0:1] + boxes_preds[..., 2:3] / 2
box1_y2 = boxes_preds[..., 1:2] + boxes_preds[..., 3:4] / 2
box2_x1 = boxes_labels[..., 0:1] - boxes_labels[..., 2:3] / 2
box2_y1 = boxes_labels[..., 1:2] - boxes_labels[..., 3:4] / 2
box2_x2 = boxes_labels[..., 0:1] + boxes_labels[..., 2:3] / 2
box2_y2 = boxes_labels[..., 1:2] + boxes_labels[..., 3:4] / 2
if box_format == 'corners':
box1_x1 = boxes_preds[..., 0:1]
box1_y1 = boxes_preds[..., 1:2]
box1_x2 = boxes_preds[..., 2:3]
box1_y2 = boxes_preds[..., 3:4]
box2_x1 = boxes_labels[..., 0:1]
box2_y1 = boxes_labels[..., 1:2]
box2_x2 = boxes_labels[..., 2:3]
box2_y2 = boxes_labels[..., 3:4]
x1 = torch.max(box1_x1, box2_x1)
y1 = torch.max(box1_y1, box2_y1)
x2 = torch.min(box1_x2, box2_x2)
y2 = torch.min(box1_y2, box2_y2)
intersection = (x2 - x1).clamp(0) * (y2 - y1).clamp(0)
box1_area = abs((box1_x2 - box1_x1) * (box1_y2 - box1_y1))
box2_area = abs((box2_x2 - box2_x1) * (box2_y2 - box2_y1))
return intersection / (box1_area + box2_area)
边栏推荐
猜你喜欢

C language: count the number of words in a paragraph

Explanation of assertions in JMeter

从别人库里拷贝的游戏如何再自己的库里显示

Matplotlib plt grid()

二、训练fashion_mnist数据集

将jar包注册为服务,实现开机自动启动

matplotlib matplotlib中plt.axis()用法

Analysis of a video website m3u8 non perceptual encryption

On the underlying index principle of MySQL

matplotlib matplotlib中plt.grid()
随机推荐
Specific usage of sklearn polynomialfeatures
1、 Construction of single neural network
[MySQL] understanding and use of indexes
The meshgrid() function in numpy
WebGL发布之后不可以输入中文解决方案
Matplotlib axvline() and axhline() functions in Matplotlib
Lvs-dr mode multi segment case
How can games copied from other people's libraries be displayed in their own libraries
Jmeter接口测试,关联接口实现步骤(token)
[untitled] * * database course design: complete the student information management system in three days**
Voiceprint Technology (II): Fundamentals of audio signal processing
[MySQL] understanding of transactions
【OpenCV】—离散傅里叶变换
On the underlying index principle of MySQL
Make a skylearn high-dimensional dataset_ Circles and make_ moons
Voiceprint Technology (I): the past and present life of voiceprint Technology
C program termination problem clr20r3 solution
Abbreviations of common English terms for IC R & D
106. simple chat room 9: use socket to transfer audio
sklearn 高维数据集制作make_circles 和 make_moons