tensorflow利用矩阵计算实现一维数据的NMS用于TimeSerialDectection

本文详细介绍了如何使用TensorFlow库在一维数据上应用非极大值抑制(NMS)技术,以进行高效的目标检测,特别适用于时序数据的检测任务。
摘要由CSDN通过智能技术生成
# 行列式相乘可以有循环遍历的效果
import tensorflow as tf
import numpy as np
def compute_overlaps(boxes):
    """Computes IoU overlaps between two sets of boxes.
    boxes1, boxes2: [N, (x1, x2)].

    For better performance, pass the largest set first and the smaller second.
    """
    b1_x1, b1_x2 = \
        tf.expand_dims(boxes[:, 0],axis=-2), \
        tf.expand_dims(boxes[:, 1],axis=-2),

    b2_x1, b2_x2 = \
        tf.expand_dims(boxes[:, 0],axis=-1),\
        tf.expand_dims(boxes[:, 1],axis=-1),


    # get the corrdinates of the intersection
    inter_rect_x1 = tf.maximum(b1_x1, b2_x1)

    inter_rect_x2 = tf.minimum(b1_x2, b2_x2)

    # Intersection area
    inter_area = tf.abs(inter_rect_x2 - inter_rect_x1 + 1)

    # Union Area
    b1_area = tf.abs((b1_x2 - b1_x1 + 1))
    b2_area = tf.abs((b2_x2 - b2_x1 + 1))

    iou = inter_area / (b1_area + b2_a
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值