Exemple #1
0
 def test_compute_semantic_labels(self):
   inputs = {}
   points = tf.constant([[0.0, 0.0, 0.0],
                         [1.0, 1.0, 1.0],
                         [1.1, 1.0, 1.0],
                         [1.0, 1.1, 1.1],
                         [3.0, 3.0, 3.0],
                         [3.1, 3.0, 3.0],
                         [3.0, 3.0, 3.1],
                         [5.0, 5.0, 5.0]], dtype=tf.float32)
   inputs['points'] = points
   inputs['objects/shape/dimension'] = tf.constant([[0.5, 0.5, 0.5],
                                                    [0.5, 0.5, 0.5],
                                                    [0.5, 0.5, 0.5]],
                                                   dtype=tf.float32)
   inputs['objects/pose/R'] = tf.constant([[[1.0, 0.0, 0.0],
                                            [0.0, 1.0, 0.0],
                                            [0.0, 0.0, 1.0]],
                                           [[1.0, 0.0, 0.0],
                                            [0.0, 1.0, 0.0],
                                            [0.0, 0.0, 1.0]],
                                           [[1.0, 0.0, 0.0],
                                            [0.0, 1.0, 0.0],
                                            [0.0, 0.0, 1.0]]],
                                          dtype=tf.float32)
   inputs['objects/pose/t'] = tf.constant([[0.0, 0.0, 0.0],
                                           [1.0, 1.0, 1.0],
                                           [3.0, 3.0, 3.0]], dtype=tf.float32)
   inputs['objects/category/label'] = tf.constant([1, 2, 3], dtype=tf.int32)
   point_labels = waymo_object_per_frame.compute_semantic_labels(
       inputs=inputs, points_key='points', box_margin=0.1)
   expected_point_labels = tf.constant(
       [[1], [2], [2], [2], [3], [3], [3], [0]], dtype=tf.int32)
   self.assertAllEqual(point_labels.numpy(), expected_point_labels.numpy())
Exemple #2
0
  def test_compute_semantic_labels_value_error(self):
    num_points = 100
    num_objects = 10
    points = tf.random.uniform([num_points, 3],
                               minval=-5.0,
                               maxval=5.0,
                               dtype=tf.float32)
    objects_dimension = tf.random.uniform([num_objects, 3],
                                          minval=0.01,
                                          maxval=10.0,
                                          dtype=tf.float32)
    objects_rotation = tf.random.uniform([num_objects, 3, 3],
                                         minval=-1.0,
                                         maxval=1.0,
                                         dtype=tf.float32)
    objects_center = tf.random.uniform([num_objects, 3],
                                       minval=1 - .0,
                                       maxval=10.0,
                                       dtype=tf.float32)
    objects_label = tf.random.uniform([num_objects],
                                      minval=0,
                                      maxval=10,
                                      dtype=tf.int32)

    inputs = {
        'objects/shape/dimension': objects_dimension,
        'objects/pose/R': objects_rotation,
        'objects/pose/t': objects_center,
        'objects/category/label': objects_label,
    }
    with self.assertRaises(ValueError):
      waymo_object_per_frame.compute_semantic_labels(
          inputs=inputs, points_key='points', box_margin=0.1)

    inputs = {
        'points': points,
        'objects/pose/R': objects_rotation,
        'objects/pose/t': objects_center,
        'objects/category/label': objects_label,
    }
    with self.assertRaises(ValueError):
      waymo_object_per_frame.compute_semantic_labels(
          inputs=inputs, points_key='points', box_margin=0.1)

    inputs = {
        'points': points,
        'objects/shape/dimension': objects_dimension,
        'objects/pose/t': objects_center,
        'objects/category/label': objects_label,
    }
    with self.assertRaises(ValueError):
      waymo_object_per_frame.compute_semantic_labels(
          inputs=inputs, points_key='points', box_margin=0.1)

    inputs = {
        'points': points,
        'objects/shape/dimension': objects_dimension,
        'objects/pose/R': objects_rotation,
        'objects/category/label': objects_label,
    }
    with self.assertRaises(ValueError):
      waymo_object_per_frame.compute_semantic_labels(
          inputs=inputs, points_key='points', box_margin=0.1)

    inputs = {
        'points': points,
        'objects/shape/dimension': objects_dimension,
        'objects/pose/R': objects_rotation,
        'objects/pose/t': objects_center,
    }
    with self.assertRaises(ValueError):
      waymo_object_per_frame.compute_semantic_labels(
          inputs=inputs, points_key='points', box_margin=0.1)