def test_inputs_missing_image_raises_value_error(self): inputs = { 'depth': tf.ones((50, 50, 1)), 'ignore_label': 255, } with self.assertRaises(ValueError): preprocessor.preprocess(inputs=inputs)
def test_points_with_wrong_dimension_raises_value_error(self): inputs = { 'points': tf.zeros((1000, 1, 3)), 'normals': tf.zeros((1000, 1, 3)), 'colors': tf.zeros((1000, 3), dtype=tf.uint8), 'semantic_labels': tf.zeros((1000, 1), dtype=tf.int32), } with self.assertRaises(ValueError): preprocessor.preprocess(inputs=inputs)
def test_preprocess_points_with_padding(self): for is_training in [True, False]: points = tf.random.uniform( (1000, 3), minval=10.0, maxval=50.0, dtype=tf.float32) normals = tf.random.uniform( (1000, 3), minval=-0.5, maxval=0.5, dtype=tf.float32) colors = tf.random.uniform((1000, 3), minval=0, maxval=255, dtype=tf.int32) semantic_labels = tf.random.uniform((1000, 1), minval=0, maxval=10, dtype=tf.int32) colors = tf.cast(colors, dtype=tf.uint8) points_centered = points - tf.expand_dims( tf.reduce_mean(points, axis=0), axis=0) points_centered = tf.pad(points_centered, paddings=[[0, 1000], [0, 0]]) inputs = { 'points': points, 'normals': normals, 'colors': colors, 'semantic_labels': semantic_labels, 'ignore_label': 255, } inputs = preprocessor.preprocess( inputs=inputs, z_min_degree_rotation=-50.0, z_max_degree_rotation=50.0, is_training=is_training, points_pad_or_clip_size=2000) self.assertEqual(inputs['ignore_label'], 255) inputs = { k: v for k, v in six.iteritems(inputs) if isinstance(v, tf.Tensor) } self.assertEqual( [2000, 3], list(inputs[standard_fields.InputDataFields.point_positions].shape)) self.assertEqual( [2000, 3], list(inputs[standard_fields.InputDataFields.point_normals].shape)) self.assertEqual( [2000, 3], list(inputs[standard_fields.InputDataFields.point_colors].shape)) self.assertEqual( [2000, 1], list( inputs[standard_fields.InputDataFields.point_loss_weights].shape)) self.assertEqual(1000, inputs[standard_fields.InputDataFields.num_valid_points]) self.assertAllClose( points_centered.numpy()[:, 2], inputs[standard_fields.InputDataFields.point_positions].numpy()[:, 2])
def test_empty_inputs_raises_value_error(self): with self.assertRaises(ValueError): empty_input = {} preprocessor.preprocess(inputs=empty_input)