Exemple #1
0
 def test_with_no_scores_field(self):
   boxlist = np_box_list_ops.copy_boxlist(boxlist=self.boxlist)
   max_output_size = 3
   iou_threshold = 0.5
   with self.assertRaises(ValueError):
     np_box_list_ops.non_max_suppression3d(boxlist, max_output_size,
                                           iou_threshold)
Exemple #2
0
  def test_multiclass_nms(self):
    boxlist = np_box_list_ops.copy_boxlist(boxlist=self.boxlist)
    scores = np.array([[-0.2, 0.1, 0.5, -0.4, 0.3], [0.7, -0.7, 0.6, 0.2, -0.9],
                       [0.4, 0.34, -0.9, 0.2, 0.31], [0.1, 0.2, 0.3, 0.4, 0.5],
                       [-0.1, 0.1, -0.1, 0.1, -0.1], [0.3, 0.2, 0.1, 0.0, -0.1],
                       [0.0, 0.0, 0.0, 0.0, 0.0]],
                      dtype=np.float32)
    boxlist.add_field('scores', scores)
    boxlist_clean = np_box_list_ops.multi_class_non_max_suppression3d(
        boxlist, score_thresh=0.25, iou_thresh=0.1, max_output_size=3)

    scores_clean = boxlist_clean.get_field('scores')
    classes_clean = boxlist_clean.get_field('classes')
    expected_scores = np.array([0.7, 0.6, 0.5, 0.4, 0.34, 0.3])
    expected_classes = np.array([0, 2, 4, 3, 1, 0])
    expected_boxes = np.array(
        [[_degree_to_radians(10.0), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0],
         [_degree_to_radians(10.0), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0],
         [_degree_to_radians(-10.0), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0],
         [_degree_to_radians(-10.0), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0],
         [_degree_to_radians(20.0), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0],
         [_degree_to_radians(10.0), 1.0, 1.0, 1.0, 10.0, 0.0, 0.0]],
        dtype=np.float32)
    self.assertAllClose(scores_clean, expected_scores)
    self.assertAllClose(classes_clean, expected_classes)
    self._compare_boxlist_with_boxes(boxlist_clean, expected_boxes)
Exemple #3
0
 def test_filter_scores_greater_than(self):
   boxlist = np_box_list_ops.copy_boxlist(boxlist=self.boxlist)
   boxlist.add_field('scores', np.array([0.8, 0.2, 0.7, 0.4], np.float32))
   boxlist_greater = np_box_list_ops.filter_scores_greater_than3d(boxlist, 0.5)
   expected_boxes_greater = np.array(
       [[_degree_to_radians(0.1), 1.0, 3.0, 4.0, 1.0, 6.0, 8.0],
        [_degree_to_radians(0.1), 1.0, 4.0, 3.0, 2.0, 7.0, 5.0]],
       dtype=np.float32)
   self._compare_boxlist_with_boxes(boxlist_greater, expected_boxes_greater)