Implementation of Neural Style Transfer from the paper A Neural Algorithm of Artistic Style in Tensorflow
- tensorflow-gpu==1.4.0
- tqdm==4.23.0
- scikit-image==0.13.1
- Create folder named
pretrained_model
- Download pretrained VGG 19 and put it into
pretrained_model
folder - Open terminal and type the command
- Command usage:
python nst.py [-h] -c CONTENT_IMG -s STYLE_IMG [-o OUTPUT_FOLDER]
[-n N_ITERATIONS] [-e SAVE_EVERY_N_ITERATIONS] [-f OUTPUT_NAME]
[-p PRETRAINED_MODEL] [-a ALPHA] [-b BETA] [-lr LEARNING_RATE]
[-ht HEIGHT] [-w WIDTH] [-ch CHANNELS]
- Command arguments:
-h, --help show this help message and exit
-c CONTENT_IMG, --content_img CONTENT_IMG
path to content image
-s STYLE_IMG, --style_img STYLE_IMG
path to style image
-o OUTPUT_FOLDER, --output_folder OUTPUT_FOLDER
path to output folder
-n N_ITERATIONS, --n_iterations N_ITERATIONS
number of iterations
-e SAVE_EVERY_N_ITERATIONS, --save_every_n_iterations SAVE_EVERY_N_ITERATIONS
every n iterations the model will save an output image
-f OUTPUT_NAME, --output_name OUTPUT_NAME
output image name
-p PRETRAINED_MODEL, --pretrained_model PRETRAINED_MODEL
path to pretraned model
-a ALPHA, --alpha ALPHA
importance of content cost
-b BETA, --beta BETA importance of style cost
-lr LEARNING_RATE, --learning_rate LEARNING_RATE
learning rate
-ht HEIGHT, --height HEIGHT
height of image
-w WIDTH, --width WIDTH
width of image
-ch CHANNELS, --channels CHANNELS
channels of image
python nst.py -c example/cat2.jpg -s example/starry_night.jpg -n 400 -e 100
- Iteration 0:
- Iteration 100:
- Iteration 200:
- Iteration 300:
- Final (Iteration 400):
用Tensorflow实现神经风格迁移, 论文:A Neural Algorithm of Artistic Style
- tensorflow-gpu==1.4.0
- tqdm==4.23.0
- scikit-image==0.13.1
- 创建文件夹
pretrained_model
- 下载 训练过的 VGG 19,并放到
pretrained_model
文件夹里 - 打开终端执行命令行
- 命令行使用方法:
python nst.py [-h] -c CONTENT_IMG -s STYLE_IMG [-o OUTPUT_FOLDER]
[-n N_ITERATIONS] [-e SAVE_EVERY_N_ITERATIONS] [-f OUTPUT_NAME]
[-p PRETRAINED_MODEL] [-a ALPHA] [-b BETA] [-lr LEARNING_RATE]
[-ht HEIGHT] [-w WIDTH] [-ch CHANNELS]
- 命令行参数:
-h, --help 显示帮助信息并退出
-c CONTENT_IMG, --content_img CONTENT_IMG
内容图片文件路径
-s STYLE_IMG, --style_img STYLE_IMG
风格图片文件路径
-o OUTPUT_FOLDER, --output_folder OUTPUT_FOLDER
输出文件夹路径
-n N_ITERATIONS, --n_iterations N_ITERATIONS
迭代次数
-e SAVE_EVERY_N_ITERATIONS, --save_every_n_iterations SAVE_EVERY_N_ITERATIONS
保存生成图片的间隔次数
-f OUTPUT_NAME, --output_name OUTPUT_NAME
输出图片名
-p PRETRAINED_MODEL, --pretrained_model PRETRAINED_MODEL
预训练模型路径
-a ALPHA, --alpha ALPHA
内容损失值权重
-b BETA, --beta BETA 风格损失值权重
-lr LEARNING_RATE, --learning_rate LEARNING_RATE
学习率
-ht HEIGHT, --height HEIGHT
图片高度
-w WIDTH, --width WIDTH
图片宽度
-ch CHANNELS, --channels CHANNELS
图片通道数
python nst.py -c example/cat2.jpg -s example/starry_night.jpg -n 400 -e 100
- 迭代0次:
- 迭代100次:
- 迭代200次:
- 迭代300次:
- 最终结果 (迭代400次):