예제 #1
0
 def __init__(self,
              flags,
              normalize_points=NormalizePoints,
              point_dataset=PointDataset,
              transform_points=TransformPoints):
     self.flags = flags
     if flags.dtype == 'points':
         self.dataset = point_dataset(ParseExample(**flags),
                                      normalize_points(),
                                      transform_points(**flags),
                                      Points2Octree(**flags))
     elif flags.dtype == 'octree':
         self.dataset = OctreeDataset(ParseExample(**flags))
     else:
         print('Error: unsupported datatype ' + flags.dtype)
예제 #2
0
    def __call__(self, points):
        angle, scale, jitter, ratio, dim, angle, stddev = 0.0, 1.0, 0.0, 0.0, 0, 0, 0

        if self.distort:
            angle = [0, 0, 0]
            for i in range(3):
                interval = self.interval[i] if self.interval[i] > 1 else 1
                rot_num = self.angle[i] // interval
                rnd = tf.random.uniform(shape=[],
                                        minval=-rot_num,
                                        maxval=rot_num,
                                        dtype=tf.int32)
                angle[i] = tf.cast(
                    rnd, dtype=tf.float32) * (interval * 3.14159265 / 180.0)
            angle = tf.stack(angle)

            minval, maxval = 1 - self.scale, 1 + self.scale
            scale = tf.random.uniform(shape=[3],
                                      minval=minval,
                                      maxval=maxval,
                                      dtype=tf.float32)
            if self.uniform_scale:
                scale = tf.stack([scale[0]] * 3)

            minval, maxval = -self.jitter, self.jitter
            jitter = tf.random.uniform(shape=[3],
                                       minval=minval,
                                       maxval=maxval,
                                       dtype=tf.float32)

            minval, maxval = self.dropout[0], self.dropout[1]
            ratio = tf.random.uniform(shape=[],
                                      minval=minval,
                                      maxval=maxval,
                                      dtype=tf.float32)
            minval, maxval = self.drop_dim[0], self.drop_dim[1]
            dim = tf.random.uniform(shape=[],
                                    minval=minval,
                                    maxval=maxval,
                                    dtype=tf.int32)
            # dim = tf.cond(tf.random_uniform([], 0, 1) > 0.5, lambda: 0,
            #     lambda: tf.random.uniform(shape=[], minval=minval, maxval=maxval, dtype=tf.int32))

            stddev = [
                tf.random.uniform(shape=[], minval=0, maxval=s)
                for s in self.stddev
            ]
            stddev = tf.stack(stddev)

        radius, center = tf.constant(1.0), tf.constant([0.0, 0.0, 0.0])
        points = transform_points(points,
                                  angle=angle,
                                  scale=scale,
                                  jitter=jitter,
                                  radius=radius,
                                  center=center,
                                  axis=self.axis,
                                  depth=self.depth,
                                  offset=self.offset,
                                  ratio=ratio,
                                  dim=dim,
                                  stddev=stddev)
        # The range of points is [-1, 1]
        return points  # TODO: return the transformations