def test_different_iou_threshold(self):
    boxes = np.array([[0, 0, 20, 100], [0, 0, 20, 80], [200, 200, 210, 300], [200, 200, 210, 250]], dtype=float)
    boxlist = np_box_list.BoxList(boxes)
    boxlist.add_field('scores', np.array([0.9, 0.8, 0.7, 0.6]))
    max_output_size = 4
    iou_threshold = 0.4
    expected_boxes = np.array([[0, 0, 20, 100], [200, 200, 210, 300]], dtype=float)
    nms_boxlist = np_box_list_ops.non_max_suppression(boxlist, max_output_size, iou_threshold)
    self.assertAllClose(nms_boxlist.get(), expected_boxes)
    iou_threshold = 0.5
    expected_boxes = np.array([[0, 0, 20, 100], [200, 200, 210, 300], [200, 200, 210, 250]], dtype=float)
    nms_boxlist = np_box_list_ops.non_max_suppression(boxlist, max_output_size, iou_threshold)
    self.assertAllClose(nms_boxlist.get(), expected_boxes)
    iou_threshold = 0.8
    expected_boxes = np.array([[0, 0, 20, 100], [0, 0, 20, 80], [200, 200, 210, 300], [200, 200, 210, 250]], dtype=float)
    nms_boxlist = np_box_list_ops.non_max_suppression(boxlist, max_output_size, iou_threshold)
    self.assertAllClose(nms_boxlist.get(), expected_boxes)
def test_different_iou_threshold(self):
    boxes = np.array([[0, 0, 20, 100], [0, 0, 20, 80], [200, 200, 210, 300], [200, 200, 210, 250]], dtype=float)
    boxlist = np_box_list.BoxList(boxes)
    boxlist.add_field('scores', np.array([0.9, 0.8, 0.7, 0.6]))
    max_output_size = 4
    iou_threshold = 0.4
    expected_boxes = np.array([[0, 0, 20, 100], [200, 200, 210, 300]], dtype=float)
    nms_boxlist = np_box_list_ops.non_max_suppression(boxlist, max_output_size, iou_threshold)
    self.assertAllClose(nms_boxlist.get(), expected_boxes)
    iou_threshold = 0.5
    expected_boxes = np.array([[0, 0, 20, 100], [200, 200, 210, 300], [200, 200, 210, 250]], dtype=float)
    nms_boxlist = np_box_list_ops.non_max_suppression(boxlist, max_output_size, iou_threshold)
    self.assertAllClose(nms_boxlist.get(), expected_boxes)
    iou_threshold = 0.8
    expected_boxes = np.array([[0, 0, 20, 100], [0, 0, 20, 80], [200, 200, 210, 300], [200, 200, 210, 250]], dtype=float)
    nms_boxlist = np_box_list_ops.non_max_suppression(boxlist, max_output_size, iou_threshold)
    self.assertAllClose(nms_boxlist.get(), expected_boxes)