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日
