Deep photo style transfer在windows10上运行

工程地址

https://github.com/LouieYang/deep-photo-styletransfer-tf

环境

  • python3.7
  • cuda10.0
  • cudnn-10.0-windows10-x64-v7.6.1.34
  • tensorflow-gpu1.14.0
  • numpy1.16.0
  • pillow6.2.1
  • scipy1.2.1
  • pycuda2019.1.2

下载权重

链接:https://pan.baidu.com/s/10RHyJHE98cSZ8uDar7puRw 
提取码:u3h2 

VGG-19模型的权重矩阵由TensorFlow版本的VGG模型微调得到,仅对类别接口进行了少量修改,VGG-19模型权重被存储为npy文件。下载后,将该权重文件复制到此目录下./project/vgg19。

修改地址

1.  使用时你只需要给出目标图像路径(content image)、风格图像路径(style image)、目标图像分割路径(content image segmentation)和风格图像分割路径(style image segmentation),即可运行命令。

python deep_photostyle.py --content_image_path  --style_image_path  --content_seg_path  --style_seg_path  --style_option 2

具体的例子为:

python deep_photostyle.py --content_image_path ./examples/input/in11.png --style_image_path ./examples/style/tar11.png --content_seg_path ./examples/segmentation/in11.png --style_seg_path ./examples/segmentation/tar11.png --style_option 2

 2. 其他选项。设置style_option的值,可得到三种不同的风格迁移方式。当style_option为0时,可得到分割后的中间结果,与Torch代码中neuralstyle_seg.lua文件相似;当style_option为1时,进一步使用这个中间结果生成最终结果,与Torch代码中deepmatting_seg.lua文件相似;当style_option为2时,将这两个步骤组合为一行命令,直接生成最终结果。

运行命令 python deep_photostyle.py -help 可查看所有选项。

上面是在终端下运行,如果需要在pycharm中运行,则需要修改这几个获取地址参数的代码,具体如下,在deep_photostyle.py中修改如下几个地址。

parser.add_argument("--content_image_path", dest='content_image_path',  nargs='?', default="E:/work/private/neural_style/deep-photo-styletransfer-tf-master/examples/mytest/input/1.jpg",
                    help="Path to the content image")
parser.add_argument("--style_image_path",   dest='style_image_path',    nargs='?', default="E:/work/private/neural_style/deep-photo-styletransfer-tf-master/examples/mytest/style/style_wave.jpg",
                    help="Path to the style image")
parser.add_argument("--content_seg_path",   dest='content_seg_path',    nargs='?', default="E:/work/private/neural_style/deep-photo-styletransfer-tf-master/examples/mytest/segmentation/input.png",
                    help="Path to the style segmentation")
parser.add_argument("--style_seg_path",     dest='style_seg_path',      nargs='?', default="E:/work/private/neural_style/deep-photo-styletransfer-tf-master/examples/mytest/segmentation/style.png",
                    help="Path to the style segmentation")



parser.add_argument("--style_option",       dest='style_option',        nargs='?', type=int,
                    help="0=non-Matting, 1=only Matting, 2=first non-Matting, then Matting", default=2)

如果运行成功如下图所示: 

Deep photo style transfer在windows10上运行_第1张图片

你可能感兴趣的:(机器学习,Python,论文笔记)