Beispiel #1
0
def generate_pose(image_size, pose_rep_type, num_landmarks):
    inps = Input(list(image_size) + [3], name='inps')

    cf_model = content_features_model(inps.get_shape().as_list(),
                                      'block3_conv1')
    for layer in cf_model.layers:
        layer.trainable = False

    reference = cf_model(inps)

    feature = Dense(
        64, input_shape=(reference.get_shape().as_list()[-1], ))(reference)

    weight = Flatten(name='flatten')(reference)
    weight = Dense(128)(weight)
    weight = LeakyReLU(0.2)(weight)
    weight = Dense(64)(weight)
    weight = Reshape((1, 1, 64), input_shape=(64, ))(weight)

    out = Multiply()([feature, weight])

    out = SizeTransformLayer(tuple(inps.get_shape().as_list()[:-1] +
                                   [64]))(out)
    out = Dense(num_landmarks, input_shape=(64, ))(out)

    return Model(inputs=[inps], outputs=[out])