Fast Neural Style在win10上运行

fast-neural-style-master(pytorch)https://github.com/pytorch/examples/tree/master/fast_neural_style(测试的该例子)
fast-neural-style-tensorflow-master(tensorflow):https://github.com/hzy46/fast-neural-style-tensorflow(没有测试)

环境

  • python3.7
  • cuda10.0
  • cudnn-10.0-windows10-x64-v7.6.1.34
  • numpy1.16.0
  • pillow6.2.1
  • scipy1.2.1
  • pytorch1.2.0
  • torchvision0.4.0

权重下载

链接:https://pan.baidu.com/s/1iWS0em5bZvkVC0CSTHotDg 
提取码:ublc

测试

python neural_style/neural_style.py eval --content-image </path/to/content/image> --model </path/to/saved/model> --output-image </path/to/output/image> --cuda 0

  • --content-image: path to content image you want to stylize.内容图像
  • --model: saved model to be used for stylizing the image (eg: mosaic.pth)模型,其实就是风格图片最终生成的
  • --output-image: path for saving the output image.输出图像
  • --content-scale: factor for scaling down the content image if memory is an issue (eg: value of 2 will halve the height and width of content-image)
  • --cuda: set it to 1 for running on GPU, 0 for CPU.

例如我测试的代码

E:\work\private\neural_style\examples-master\fast_neural_style>python neural_style/neural_style.py eval --content-image E:\work\private\neural_style\examples-master\fast_neural_style\images\content-images\amber.jpg --model E:\work\private\neural_style\examples-master\fast_neural_style\saved_models\candy.pth --output-image E:\work\private\neural_style\examples-master\fast_neural_style\out.png --cuda 1 

内容图像

风格图像(其实就是save_models中解压出来的candy.pth)

输出图像

训练

python neural_style/neural_style.py train --dataset </path/to/train-dataset> --style-image </path/to/style/image> --save-model-dir </path/to/save-model/folder> --epochs 2 --cuda 1

  • --dataset: path to training dataset, the path should point to a folder containing another folder with all the training images. I used COCO 2014 Training images dataset [80K/13GB] (download).
  • --style-image: path to style-image.
  • --save-model-dir: path to folder where trained model will be saved.
  • --cuda: set it to 1 for running on GPU, 0 for CPU.

Refer to neural_style/neural_style.py for other command line arguments. For training new models you might have to tune the values of --content-weight and --style-weight. The mosaic style model shown above was trained with --content-weight 1e5 and --style-weight 1e10. The remaining 3 models were also trained with similar order of weight parameters with slight variation in the --style-weight (5e10 or 1e11).

上面这段英文就告诉我们,这个内容和风格的权重由于你训练的图像不同,可能需要做出相应的改变。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值