Exemple #1
0
    return image


# New: replace random_crop with center crop
def center_crop(image, crop_size):
    image_shape = image.get_shape().as_list()
    offset_length = floor(float(crop_size / 2))
    x_start = floor(image_shape[2] / 2 - offset_length)
    y_start = floor(image_shape[1] / 2 - offset_length)
    image = image[:, x_start:x_start + crop_size, y_start:y_start + crop_size]
    image.set_shape((3, crop_size, crop_size))
    return image


if __name__ == '__main__':
    params = get_params(train)

    parser = argparse.ArgumentParser(
        description='AdaIN Style Transfer Training')

    # general
    parser.add_argument(
        '--content_dir',
        default=params['content_dir'],
        help=
        'A directory with TFRecords files containing content images for training'
    )
    parser.add_argument(
        '--style_dir',
        default=params['style_dir'],
        help=
Exemple #2
0
        otherLayers = [vgg[i] for i in otherLayerNames]

    if decoder_weights:
        with open_weights(decoder_weights) as w:
            decoder = build_decoder(combined_target, w, trainable=False,
                data_format=data_format)
    else:
        decoder = build_decoder(combined_target, None, trainable=False,
            data_format=data_format)

    # Return other layers on top of original outputs
    return image, content, style, target, encoder, decoder, otherLayers


if __name__ == '__main__':
    params = get_params(style_transfer)
    parser = argparse.ArgumentParser(description='AdaIN Style Transfer')

    parser.add_argument('--content', help='File path to the content image')
    parser.add_argument('--content_dir', help="""Directory path to a batch of
        content images""")
    parser.add_argument('--style', help="""File path to the style image,
        or multiple style images separated by commas if you want to do style
        interpolation or spatial control""")
    parser.add_argument('--style_dir', help="""Directory path to a batch of
        style images""")
    parser.add_argument('--vgg_weights', default=params['vgg_weights'],
        help='Path to the weights of the VGG19 network')
    parser.add_argument('--decoder_weights', default=params['decoder_weights'],
        help='Path to the decoder')