Exemplo n.º 1
0
def create_pcn_encoder(inputs, args):
    with tf.variable_scope('encoder_0', reuse=tf.AUTO_REUSE):
        features = mlp_conv(inputs, [128, 256], args.phase)
        features_global = tf.reduce_max(features, axis=1, keep_dims=True, name='maxpool_0')
        features = tf.concat([features, tf.tile(features_global, [1, tf.shape(inputs)[1], 1])], axis=2)
    with tf.variable_scope('encoder_1', reuse=tf.AUTO_REUSE):
        features = mlp_conv(features, [512, args.code_nfts], args.phase)
        features = tf.reduce_max(features, axis=1, name='maxpool_1')
    return features
Exemplo n.º 2
0
    def create_decoder(self, features):
        with tf.variable_scope('decoder', reuse=tf.AUTO_REUSE):
            coarse = mlp(features, [1024, 1024, self.num_coarse * 3],
                         self.args.phase)
            coarse = tf.reshape(coarse, [-1, self.num_coarse, 3])

        with tf.variable_scope('folding', reuse=tf.AUTO_REUSE):
            grid = tf.meshgrid(tf.linspace(-0.05, 0.05, self.grid_size),
                               tf.linspace(-0.05, 0.05, self.grid_size))
            grid = tf.expand_dims(tf.reshape(tf.stack(grid, axis=2), [-1, 2]),
                                  0)
            grid_feat = tf.tile(grid,
                                [tf.shape(features)[0], self.num_coarse, 1])

            point_feat = tf.tile(tf.expand_dims(coarse, 2),
                                 [1, 1, self.grid_size**2, 1])
            point_feat = tf.reshape(point_feat, [-1, self.num_fine, 3])

            global_feat = tf.tile(tf.expand_dims(features, 1),
                                  [1, self.num_fine, 1])

            feat = tf.concat([grid_feat, point_feat, global_feat], axis=2)

            center = tf.tile(tf.expand_dims(coarse, 2),
                             [1, 1, self.grid_size**2, 1])
            center = tf.reshape(center, [-1, self.num_fine, 3])

            fine = mlp_conv(feat, [512, 512, 3], self.args.phase)
            fine = fine + center
            print(coarse.shape, fine.shape)
        return coarse, fine
Exemplo n.º 3
0
 def create_decoder(self, features):
     with tf.variable_scope('decoder', reuse=tf.AUTO_REUSE):
         x = tf.linspace(-self.grid_scale, self.grid_scale, self.grid_size)
         y = tf.linspace(-self.grid_scale, self.grid_scale, self.grid_size)
         grid = tf.meshgrid(x, y)
         grid = tf.reshape(tf.stack(grid, axis=2), [-1, 2])
         grid = tf.tile(tf.expand_dims(grid, 0),
                        [tf.shape(features)[0], 1, 1])
         features = tf.tile(tf.expand_dims(features, 1),
                            [1, self.num_output_points, 1])
         with tf.variable_scope('folding_1'):
             fold1 = mlp_conv(tf.concat([features, grid], axis=2),
                              [512, 512, 3], self.args.phase)
         with tf.variable_scope('folding_2'):
             fold2 = mlp_conv(tf.concat([features, fold1], axis=2),
                              [512, 512, 3], self.args.phase)
         print(fold1.shape, fold2.shape)
     return fold1, fold2
Exemplo n.º 4
0
def create_pointnet_encoder(inputs, args):
    with tf.variable_scope('encoder_0', reuse=tf.AUTO_REUSE):
        features = mlp_conv(inputs, [64, 128, args.code_nfts], args.phase, bn=True)
        code = tf.reduce_max(features, axis=1, name='maxpool_0')
    with tf.variable_scope('encoder_1', reuse=tf.AUTO_REUSE):
        code = mlp(code, [args.code_nfts,], args.phase)
        with tf.variable_scope('bn', reuse=tf.AUTO_REUSE):
            code = tf.layers.batch_normalization(code, training=args.phase)
        code = tf.nn.relu(code, 'relu')
    return code
Exemplo n.º 5
0
 def create_encoder(self, inputs):
     with tf.variable_scope('encoder_0', reuse=tf.AUTO_REUSE):
         features = mlp_conv(inputs, [128, 256])
         features_global = tf.reduce_max(features,
                                         axis=1,
                                         keep_dims=True,
                                         name='maxpool_0')
         print('features_global', features_global)
         features = tf.concat([
             features,
             tf.tile(features_global, [1, tf.shape(inputs)[1], 1])
         ],
                              axis=2)
         print('features', features)
     with tf.variable_scope('encoder_1', reuse=tf.AUTO_REUSE):
         features = mlp_conv(features, [512, 1024])
         print('features', features)
         features = tf.reduce_max(features, axis=1, name='maxpool_1')
         print('features', features)
     return features
Exemplo n.º 6
0
 def create_level(self, level, input_channels, output_channels, inputs, bn):
     with tf.variable_scope('level_%d' % (level), reuse=tf.AUTO_REUSE):
         features = mlp_conv(inputs, [
             input_channels,
             int(input_channels / 2),
             int(input_channels / 4),
             int(input_channels / 8),
             output_channels * int(self.args.tarch[level])
         ], self.args.phase, bn)
         features = tf.reshape(features,
                               [tf.shape(features)[0], -1, output_channels])
     return features