:py:mod:`kwimage.algo._nms_backend.py_nms` ========================================== .. py:module:: kwimage.algo._nms_backend.py_nms .. autoapi-nested-parse:: Fast R-CNN Copyright (c) 2015 Microsoft Licensed under The MIT License [see LICENSE for details] Written by Ross Girshick Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: kwimage.algo._nms_backend.py_nms.py_nms .. py:function:: py_nms(np_ltrb, np_scores, thresh, bias=1) Pure Python NMS baseline. .. rubric:: References https://github.com/rbgirshick/fast-rcnn/blob/master/lib/utils/nms.py .. rubric:: Example >>> np_ltrb = np.array([ >>> [0, 0, 100, 100], >>> [0, 0, 100, 100], >>> [100, 100, 10, 10], >>> [10, 10, 100, 100], >>> [50, 50, 100, 100], >>> [100, 100, 150, 101], >>> [120, 100, 180, 101], >>> [150, 100, 200, 101], >>> ], dtype=np.float32) >>> np_scores = np.linspace(0, 1, len(np_ltrb)) >>> thresh = 0.1 >>> bias = 0.0 >>> keep = sorted(py_nms(np_ltrb, np_scores, thresh, bias)) >>> print('keep = {!r}'.format(keep)) keep = [2, 4, 5, 7] .. rubric:: Example >>> from kwimage.algo._nms_backend.py_nms import * # NOQA >>> np_ltrb = np.array([ >>> [0, 0, 100, 100], >>> [100, 100, 10, 10], >>> [10, 10, 100, 100], >>> [50, 50, 100, 100], >>> ], dtype=np.float32) >>> np_scores = np.array([.1, .5, .9, .1]) >>> keep = list(py_nms(np_ltrb, np_scores, thresh=0.0, bias=1.0)) >>> print('keep@0.0 = {!r}'.format(keep)) >>> keep = list(py_nms(np_ltrb, np_scores, thresh=0.2, bias=1.0)) >>> print('keep@0.2 = {!r}'.format(keep)) >>> keep = list(py_nms(np_ltrb, np_scores, thresh=0.5, bias=1.0)) >>> print('keep@0.5 = {!r}'.format(keep)) >>> keep = list(py_nms(np_ltrb, np_scores, thresh=1.0, bias=1.0)) >>> print('keep@1.0 = {!r}'.format(keep)) keep@0.0 = [2, 1] keep@0.2 = [2, 1] keep@0.5 = [2, 1, 3] keep@1.0 = [2, 1, 3, 0]