Deep photo style transfer在windows10上运行

174 篇文章 40 订阅
87 篇文章 20 订阅

工程地址

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 <path_to_content_image> --style_image_path <path_to_style_image> --content_seg_path <path_to_content_segmentation> --style_seg_path <path_to_style_segmentation> --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)

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

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 12
    评论
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值