Example #1
0
 def test_gather3d_with_invalid_field_specified(self):
   indices = np.array([2, 0, 1], dtype=int)
   boxlist = self.boxlist
   with self.assertRaises(ValueError):
     np_box_list_ops.gather3d(boxlist, indices, 'labels')
   with self.assertRaises(ValueError):
     np_box_list_ops.gather3d(boxlist, indices, ['objectness'])
 def test_gather3d_with_fields_specified(self):
     indices = np.array([2, 0, 1], dtype=int)
     boxlist = self.boxlist
     subboxlist = np_box_list_ops.gather3d(boxlist, indices, ['labels'])
     self.assertFalse(subboxlist.has_field('scores'))
     expected_boxes = np.array(
         [[_degree_to_radians(0.1), 1.0, 4.0, 3.0, 2.0, 7.0, 5.0],
          [_degree_to_radians(0.1), 1.0, 3.0, 4.0, 1.0, 6.0, 8.0],
          [_degree_to_radians(0.2), 14.0, 14.0, 14.0, 15.0, 15.0, 15.0]],
         dtype=float)
     self._compare_boxlist_with_boxes(subboxlist, expected_boxes)
     expected_labels = np.array(
         [[0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 1, 0, 0, 0]], dtype=int)
     self.assertAllClose(expected_labels, subboxlist.get_field('labels'))
Example #3
0
 def test_gather3d_with_invalid_multidimensional_indices(self):
   indices = np.array([[0, 1, 4]], dtype=int)
   boxlist = self.boxlist
   with self.assertRaises(ValueError):
     np_box_list_ops.gather3d(boxlist, indices)