• 非极大值抑制-NMS


    NMS(非极大值抑制)

    NMS: non maximum suppression 
    翻译为“非极大值抑制”,为什么不翻译成最大值抑制呢?maximum可以翻译为“最大值”,也可以翻译成“极大值”,所以翻译成极大值或者最大值一定要看这个值的含义。极大值和最大值的区别就是,极大值时局部最大值。 
    NMS的作用:去掉detection任务重复的检测框。 
    用普通话翻译一下非极大值抑制:不是局部的最大值的那些值都滚蛋 
    用图片来理解一下: 
    nms1 
    图片引自:https://blog.csdn.net/shuzfan/article/details/52711706#commentsedit

    基于前面的网络(如RPN)能为每个框给出一个score,score越大证明框越接近期待值。如上图,两个目标分别有多个选择框,现在要去掉多余的选择框。分别在局部选出最大框,然后去掉和这个框IOU>0.7的框。 
    非极大值抑制嘛,就是只留下极大值的意思。只留下极大值之后,就是下面的样子了: 
    这里写图片描述 
    嗯,这个算法就是这么简单。

    下面时Fast R-CNN关于NMS的源代码(python版),Faster R-CNN也是用的这段代码。

    # --------------------------------------------------------
    # Fast R-CNN
    # Copyright (c) 2015 Microsoft
    # Licensed under The MIT License [see LICENSE for details]
    # Written by Ross Girshick
    # --------------------------------------------------------
    
    import numpy as np
    
    def py_cpu_nms(dets, thresh):
        """Pure Python NMS baseline."""
        x1 = dets[:, 0]
        y1 = dets[:, 1]
        x2 = dets[:, 2]
        y2 = dets[:, 3]
        scores = dets[:, 4]
    
        areas = (x2 - x1 + 1) * (y2 - y1 + 1)
        order = scores.argsort()[::-1]
    
        keep = []
        while order.size > 0:
            i = order[0]
            keep.append(i)
            xx1 = np.maximum(x1[i], x1[order[1:]])
            yy1 = np.maximum(y1[i], y1[order[1:]])
            xx2 = np.minimum(x2[i], x2[order[1:]])
            yy2 = np.minimum(y2[i], y2[order[1:]])
    
            w = np.maximum(0.0, xx2 - xx1 + 1)
            h = np.maximum(0.0, yy2 - yy1 + 1)
            inter = w * h
            ovr = inter / (areas[i] + areas[order[1:]] - inter)
    
            inds = np.where(ovr <= thresh)[0]
            order = order[inds + 1]
    
        return keep
  • 相关阅读:
    mouseover和mouseenter的区别 mouseenter不会冒泡,mouseleave不会冒泡;
    2021年1月24日 命令按钮控件Button 和 单选按钮控件RadioButton 和复选框按钮
    2021年1月23日 文本框控件
    2021年1月21日 画了个注册的界面
    2021年1月29日 体温上报app03
    2021年1月18日 activity的三种状态
    2021年1月16日 秒表app
    2021年1月15日 界面跳转
    1.CSS知识点——css的引入方式
    面试题 315
  • 原文地址:https://www.cnblogs.com/yumoye/p/10831398.html
Copyright © 2020-2023  润新知