本文主要是介绍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
).
上面这段英文就告诉我们,这个内容和风格的权重由于你训练的图像不同,可能需要做出相应的改变。
这篇关于Fast Neural Style在win10上运行的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!