Application of non-maximal value suppression in object detection

Source: Internet
Author: User
application of non-maximal value suppression in object detection

The application of NMS algorithm in object detection is introduced according to the source code of py_cpu_nms.py faster-rcnn. After the RPN layer in the FASTER-RCNN, some boundingbox and boundingbox corresponding to a certain class of scores (confidence degree) are obtained. So you can remove the box with a larger overlap value based on the NMS.

Import NumPy as NP def PY_CPU_NMS (Dets, Thresh): "" "Pure Python NMS baseline." "
    #dets: N*m,n is the number of bbox, the first 4 bits of M are corresponding (X1,y1,x2,y2), the 5th bit is the corresponding score #thresh: 0.3,0.5 .... X1 = dets[:, 0] y1 = dets[:, 1] x2 = dets[:, 2] y2 = dets[:, 3] scores = dets[:, 4] areas = (x2-x1 + 1) * (y2-y1 + 1) #求每个bbox的面积 order = Scores.argsort () [:: -1] #对分数进行倒排序 keep = [] #用来保存最后留下来的bbox while order.
        Size > 0:i = order[0] #无条件保留每次迭代中置信度最高的bbox keep.append (i) #计算置信度最高的bbox和其他剩下bbox之间的交叉区域 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:]) #计算置信度高的bbox和其他剩下bbox之间交叉区域的面积 w = np.maximum (0.0, xx2-xx1 + 1)  h = np.maximum (0.0, yy2-yy1 + 1) Inter = w * H #求交叉区域的面积占两者 (High confidence bbox and other bbox) area and the mandatory OVR = Inter/(Areas[i] + areas[order[1:]]-Inter) #保留ovr小于thresh的bbox, inInto the next iteration. Inds = Np.where (OVR <= thresh) [0] #因为ovr中的索引不包括order [0] so move backward one order = order[inds + 1] return ke
 Ep

The following explains the principle of using NMS to filter areas. When a window area is considered most likely to represent an object, then a proposal with a large cross area of the window area can be considered not to be the desired window area.

The above is a personal understanding of the NMS in object detection, if there is something wrong, I would like to point out. Another is to give a person feel that the NMS explained a better connection. Http://www.cnblogs.com/liekkas0626/p/5219244.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.