LoginSignup
33
27

More than 5 years have passed since last update.

pix2pixモデルを使ってみる

Last updated at Posted at 2016-12-01

はじめに

今回は最近巷で噂のpix2pixモデルをインストールし、使ってみる。ラベルから画像を生成したり、航空写真から地図を生成したりと、いろいろできるみたい。
pix2pix_01.jpg
論文はP. IsolaらのImage-to-Image Translation Using Conditional Adversarial Networks。
https://arxiv.org/pdf/1611.07004v1.pdf

ソースコードはこちら。
https://github.com/phillipi/pix2pix

著者らのホームページはこちら。
https://phillipi.github.io/pix2pix/

環境

OS:Ubuntu14.04
GPU:GTX1070
CUDA:8.0 RC
cuDNN:5.1
python2.7.6
など

Torch関連をインストール

Torchは既にインストールしてある。
http://qiita.com/masataka46/items/41f9fac011590f3cd4f1

torch関連パケージのnngraphとdesplayをインストールする。

luarocks install nngraph
luarocks install https://raw.githubusercontent.com/szym/display/master/display-scm-0.rockspec

うまくいったみたい。

Image-to-imageモデルをインストールする。

モデルをgit cloneする。

git clone https://github.com/phillipi/pix2pix.git

次にデータを持ってくる。

cd pix2pix
bash ./datasets/download_dataset.sh facades

学習させてみる

次にダウンロードしたデータセットで学習させてみる。

DATA_ROOT=./datasets/facades name=facades_generation which_direction=BtoA th train.lua

2時間半で200回の学習が終了した。

学習したモデルでテストする

最後に学習したモデルでテストする。

DATA_ROOT=./datasets/facades name=facades_generation which_direction=BtoA phase=val th test.lua

結果は./results/facades_generation/latest_net_G_val/index.htmlに保存された。以下の画像は出力結果の一部。
pix2pix_result161202.png

Outputとして生成された画像はGroundTruthとは異なるが、こんな建物は確かにありそうなので、これはこれでいいと思う。学習用データに影響されてるのだろう。

33
27
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
27