【深度学习】目标检测算法总结(R-CNN、Fast R-CNN、Faster R-CNN、FPN、YOLO、SSD、RetinaNet)

详细见 https://www.cnblogs.com/guoyaohua/p/8994246.html
这个人的其他博客也不错

深度学习中IU、IoU(Intersection over Union)的概念理解以及python程序实现
https://blog.csdn.net/iamoldpan/article/details/78799857
https://blog.csdn.net/sinat_34474705/article/details/80045294 不错的

import tensorflow as tf

def IoU_calculator(x, y, w, h, l_x, l_y, l_w, l_h):
“”"calaulate IoU
Args:
x: net predicted x
y: net predicted y
w: net predicted width
h: net predicted height
l_x: label x
l_y: label y
l_w: label width
l_h: label height

Returns:
  IoU
"""

# convert to coner
x_max = x + w/2
y_max = y + h/2
x_min = x - w/2
y_min = y - h/2

l_x_max = l_x + l_w/2
l_y_max = l_y + l_h/2
l_x_min = l_x - l_w/2
l_y_min = l_y - l_h/2
# calculate the inter
inter_x_max = tf.minimum(x_max, l_x_max)
inter_x_min = tf.maximum(x_min, l_x_min)

inter_y_max = tf.minimum(y_max, l_y_max)
inter_y_min = tf.maximum(y_min, l_y_min)

inter_w = inter_x_max - inter_x_min
inter_h = inter_y_max - inter_y_min

inter = tf.cond(tf.logical_or(tf.less_equal(inter_w,0), tf.less_equal(inter_h,0)), 
                lambda:tf.cast(0,tf.float32), 
                lambda:tf.multiply(inter_w,inter_h))
# calculate the union
union = w*h + l_w*l_h - inter

IoU = inter / union
return IoU
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值