万年素人からHackerへの道

万年素人がHackerになれるまで殴り書きするぜ。

neural-styleを使うぜMac

neural-styleは画像をDeep Learningでピカソ風にしたりとかのやつ。 Torch7,loadcaffeが必要だ。

thコマンドはTorch7のコマンドだ。

インストール

人工知能で画像合成させる「ostagram」実行環境の作り方 - Hacking My Way 〜 itogのhack日記 が参考になる。 しかし、間違っているw

git clone https://github.com/torch/distro.git --recursive torch

のようにtorchフォルダを指定するのがいい。 recursiveはサブモジュールもインストールするオプション。

CUDAのインストールしてないときに、 th neural_style.lua -style_image <image.jpg> -content_image <image.jpg> を実行するときに

Error when running without CUDA: No LuaRocks module found for cutorch

エラーが出る。

Error when running without CUDA: No LuaRocks module found for cutorch · Issue #14 · jcjohnson/neural-style · GitHub

ここ見ると分かるようにGPUを外すオプション-gpu -1

th neural_style.lua -style_image examples/inputs/picasso_selfport1907.jpg -content_image examples/inputs/brad_pitt.jpg  -gpu -1

ちなみに、style_imageは画風の参考にさせる画像、content_imageは元絵。

僕はピカソの自画像を画風にブラッドピットを元絵にした。(今後githubから消されるかも?)

neural-styleフォルダ内で実行した。