def classify(self, affinity_pred, name, is_training=True, reuse=False): """ Predicts whether the 2 image patches are from the same image """ with tf.compat.v1.variable_scope(name, reuse=reuse): x = slim.stack(affinity_pred, slim.fully_connected, [512], scope='fc') out = slim.fully_connected(x, 1, activation_fn=None, scope='fc_out') return out
def predict(self, feat_ab, name, reuse=False): with tf.compat.v1.variable_scope(name, reuse=reuse): in_size = int(feat_ab.get_shape()[1]) out = slim.stack(feat_ab, slim.fully_connected, [4096, 2048, 1024], scope='fc') out = slim.fully_connected(out, self.num_classes, activation_fn=None, scope='fc_out') return out
def classify_with_feat(self, im_a_feat, im_b_feat, affinity_pred, name, is_training=True, reuse=False): """ Predicts whether the 2 image patches are from the same image """ with tf.compat.v1.variable_scope(name, reuse=reuse): x = tf.concat([im_a_feat, im_b_feat, affinity_pred], axis=-1) x = slim.stack(x, slim.fully_connected, [4096, 1024], scope='fc') out = slim.fully_connected(x, 1, activation_fn=None, scope='fc_out') return out
def pointnet_encoder(point_cloud, conv_layers=[16, 32, 64], fc_layers=[128], dim_output=128, dropout_rate=0.5, normalizer_fn=NORMALIZER_FN, normalizer_params=NORMALIZER_PARAMS, is_training=False, scope=None): """PointNet encoder for feature extraction. Args: point_cloud: The input point cloud. conv_layers: List of number of channels for convolutional layers. fc_layers: List of dimensions for fully-connected layers. dim_output: Output dimension. dropout_rate: Dropout rate of the fully-connected layers. normalizer_fn: Normalizer function. normalizer_params: Normalizer parameters. is_training: True if it is the training mode. scope: Scope of the module. Returns: net: A tensor of shape [batch_size, dim_output]. end_points: List of intermediate layers. """ end_points = {} with tf.compat.v1.variable_scope(scope, default_name='pointnet', reuse=tf.compat.v1.AUTO_REUSE): with slim.arg_scope([slim.dropout, slim.batch_norm], is_training=is_training): with slim.arg_scope([slim.conv2d, slim.fully_connected], activation_fn=tf.nn.relu, normalizer_fn=normalizer_fn, normalizer_params=normalizer_params): net = point_cloud net = slim.stack(net, slim.fully_connected, conv_layers, scope='conv') end_points['final_conv'] = net net = tf.reduce_max(net, axis=-2, name='max_pool') end_points['max_pool'] = net if fc_layers: for i, num_filters in enumerate(fc_layers): layer_name = 'fc%d' % (i + 1) net = slim.fully_connected(net, 128, scope=layer_name) end_points[layer_name] = net if dropout_rate is not None: layer_name = 'dropout%d' % (i + 1) keep_prob = 1.0 - dropout_rate net = slim.dropout(net, keep_prob=keep_prob, scope=layer_name) end_points[layer_name] = net net = slim.fully_connected(net, dim_output, activation_fn=None, normalizer_fn=None, scope='output') end_points['output'] = net return net, end_points