예제 #1
0
 def testRandomPadOrTrimToEmpty(self):
     points = tf.constant([[1., 2., 3.]])
     features = tf.constant([[100.]])
     points, features = detection_3d_lib.RandomPadOrTrimTo(
         [points[0:0], features[0:0]], 10, seed=123)[0]
     with self.session() as sess:
         points_np, features_np = sess.run([points, features])
         self.assertAllClose(points_np, np.zeros(shape=(10, 3)))
         self.assertAllClose(features_np, np.zeros(shape=(10, 1)))
예제 #2
0
    def testRandomPadOrTrimToTrim(self):
        points = tf.constant([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.],
                              [10., 11., 12.]])
        features = tf.constant([[100.], [200.], [300.], [400.]])

        points, features = detection_3d_lib.RandomPadOrTrimTo(
            [points, features], 2, seed=123)[0]
        with self.session() as sess:
            points_np, features_np = sess.run([points, features])
            # Slicing choose a random 2 points.
            self.assertAllClose([[1., 2., 3.], [10., 11., 12.]], points_np)
            self.assertAllClose([[100.], [400.]], features_np)
예제 #3
0
    def testRandomPadOrTrimToPad(self):
        points = tf.constant([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.],
                              [10., 11., 12.]])
        features = tf.constant([[100.], [200.], [300.], [400.]])

        points, features = detection_3d_lib.RandomPadOrTrimTo(
            [points, features], 10, seed=123)[0]
        with self.session() as sess:
            points_np, features_np = sess.run([points, features])
            # Padding repeats a random set of points.
            self.assertAllClose([[1., 2., 3.], [1., 2., 3.], [10., 11., 12.],
                                 [7., 8., 9.], [7., 8., 9.], [4., 5., 6.]],
                                points_np[4:])
            self.assertAllClose(
                [[100.], [100.], [400.], [300.], [300.], [200.]],
                features_np[4:])