【图片】机器学习--名画风格 neural-style

        neural-style

学习画作风格,将风格施加到另外一张图片中

例如将名画《星夜》的风格施加到一副建筑照片中:

源码 https://github.com/jcjohnson/neural-style

安装步骤:

  1.torch7

  2.loadcaff

  torch7的安装详见 前文:开源 人脸识别 openface 实用介绍 实例演示 训练自己的模型

  loadcaff的安装:

1 sudo apt-get install libprotobuf-dev protobuf-compiler
2 git clone https://github.com/szagoruyko/loadcaffe.git
3 cd loadcaffe
4 luarocks install loadcaffe-1.0-0.rockspec

  neural-style的安装:

1 git clone https://github.com/jcjohnson/neural-style.git
2 cd neural-style
3 sh models/download_models.sh

  经过第三步,下载好模型之后就可以运行了。注意,内存占用较大,一定要有足够内存否则不能运行,建议分配9GB内存,虚拟机宿主机最好有16GB内存。

  试运行:使用CPU模式(-gpu -1),此时cpu核心全开,cpu核数越多越快,4核3.3GHz 跑完一次大约需要40分钟。

th neural_style.lua -gpu -1 -print_iter 1

  基本功能:使用style_image作为风格,content_image为等待修改图片,程序会自动合成第三张图片。

th neural_style.lua -gpu -1 -print_iter 1 -style_image <image.jpg> -content_image <image.jpg> 

   网上找了一张川普的动感图:

给女神施加一下:

结果:

 =========完=========

2017年4月16日

  

 

posted @ 2017-04-16 13:04  熊猫滚滚  阅读(3329)  评论(0编辑  收藏  举报