def endpoints(image, is_training):
    if image.get_shape().ndims != 4:
        raise ValueError('Input must be of size [batch, height, width, 3]')

    #image = image - tf.constant(_RGB_MEAN, dtype=tf.float32, shape=(1,1,1,3))

    with tf.contrib.slim.arg_scope(
            resnet_arg_scope(batch_norm_decay=0.9, weight_decay=0.0)):
        _, endpoints = resnet_v1_50(image,
                                    num_classes=None,
                                    is_training=is_training,
                                    global_pool=True)

    resnet_out_shape = endpoints['img_var/resnet_v1_50/block4'].get_shape()
    num_feature = resnet_out_shape[1] * resnet_out_shape[2]
    NetVLAD = lp.NetVLAD(feature_size=2048,
                         max_samples=num_feature,
                         cluster_size=16,
                         output_dim=1000,
                         gating=True,
                         add_batch_norm=True,
                         is_training=is_training)

    endpoints['vlad_in'] = tf.reshape(endpoints['img_var/resnet_v1_50/block4'],
                                      [-1, 2048])
    endpoints['vlad_out'] = NetVLAD.forward(endpoints['vlad_in'])

    return endpoints['vlad_out'], 'resnet_v1_50'
Пример #2
0
def endpoints(image, pc_trans_feat, is_training):
    if image.get_shape().ndims != 4:
        raise ValueError('Input must be of size [batch, height, width, 3]')

    image = image - tf.constant(
        _RGB_MEAN, dtype=tf.float32, shape=(1, 1, 1, 3))

    with tf.contrib.slim.arg_scope(
            resnet_arg_scope(batch_norm_decay=0.9, weight_decay=0.0)):
        _, endpoints = resnet_v1_50(image,
                                    num_classes=None,
                                    is_training=is_training,
                                    global_pool=True)

    if not pc_trans_feat is None:
        concat_feat = tf.concat(
            (endpoints['img_var/resnet_v1_50/block4'], pc_trans_feat), axis=3)
        conv_feat = tf.layers.conv2d(concat_feat,
                                     2048,
                                     3,
                                     activation=tf.nn.relu)
        img_pc_feat = tf.reduce_mean(conv_feat, [1, 2], name='pool6')
        img_pc_feat = tf.layers.dense(img_pc_feat, 1000, activation=tf.nn.relu)
        img_pc_feat = tf.nn.l2_normalize(img_pc_feat, 1)
    else:
        img_pc_feat = None

    img_feat = tf.reduce_mean(endpoints['img_var/resnet_v1_50/block4'], [1, 2],
                              name='pool5')
    img_feat = tf.layers.dense(img_feat, 1000, activation=tf.nn.relu)
    img_feat = tf.nn.l2_normalize(img_feat, 1)

    return img_feat, img_pc_feat
def endpoints(pcai, is_training):

    with tf.contrib.slim.arg_scope(
            resnet_arg_scope(batch_norm_decay=0.9, weight_decay=0.0)):
        _, endpoints = resnet_v1_fusion(pcai,
                                        num_classes=None,
                                        is_training=is_training,
                                        global_pool=False)

    #print(endpoints['fusion_var/resnet_v1_fusion/block1'])

    endpoints['final_pooling'] = tf.reduce_mean(
        endpoints['fusion_var/resnet_v1_fusion/block1'], [1, 2], name='pool5')
    endpoints['model_output'] = tf.layers.dense(endpoints['final_pooling'],
                                                1024)
    return endpoints, 'resnet_v1_50'
def endpoints(image, is_training):
    if image.get_shape().ndims != 4:
        raise ValueError('Input must be of size [batch, height, width, 3]')

    image = image - tf.constant(
        _RGB_MEAN, dtype=tf.float32, shape=(1, 1, 1, 3))

    with tf.contrib.slim.arg_scope(
            resnet_arg_scope(batch_norm_decay=0.9, weight_decay=0.0)):
        _, endpoints = resnet_v1_50(image,
                                    num_classes=None,
                                    is_training=is_training,
                                    global_pool=True)

    endpoints['model_output'] = endpoints['global_pool'] = tf.reduce_mean(
        endpoints['img_var/resnet_v1_50/block4'], [1, 2], name='pool5')

    return endpoints['img_var/resnet_v1_50/block4'], endpoints[
        'model_output'], 'resnet_v1_50'