From d8156a7dc2cc98219d10958be92e399a674d271a Mon Sep 17 00:00:00 2001 From: Hikaru Ikuta Date: Thu, 8 Oct 2015 18:23:31 +0900 Subject: [PATCH 01/11] Fix error for CPU execution --- chainer-gogh-multi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chainer-gogh-multi.py b/chainer-gogh-multi.py index b5696cb..c5399eb 100644 --- a/chainer-gogh-multi.py +++ b/chainer-gogh-multi.py @@ -103,7 +103,7 @@ def generate_image(img_orig, img_style, width, nw, nh, max_iter, lr, img_gen=Non img_gen = xp.random.uniform(-20,20,(batch_size,3,width,width),dtype=np.float32) img_gen[:,:,:,:] = img_gen_ else: - img_gen = np.random.uniform(-20,20,(batch_size,3,width,width)).astype(np.float32) + img_gen_ = np.random.uniform(-20,20,(3,width,width)).astype(np.float32) img_gen = np.random.uniform(-20,20,(batch_size,3,width,width)).astype(np.float32) img_gen[:,:,:,:] = img_gen_ x = Variable(img_gen) From ec0a0bb8ea509e801fc9cca872ac97b29be294ca Mon Sep 17 00:00:00 2001 From: mattya Date: Mon, 30 Jan 2017 12:32:08 +0900 Subject: [PATCH 02/11] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3b9fe32..78ddb75 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,8 @@ pip install chainer お手軽。(`-m nin`) * VGG https://gist.github.com/ksimonyan/211839e770f7b538e2d8#file-readme-md -きれいな絵がかけるがとても重い。(`-m vgg`) +きれいな絵がかけるがとても重い。(`-m vgg`, `-m vgg_chainer`) +vgg_chainerではモデルのダウンロードの必要はなく、初回を除いて非常に高速でロードできるようになります(chainer 1.19以降で動作)。 * GoogLeNet https://github.com/BVLC/caffe/tree/master/models/bvlc_googlenet @@ -63,14 +64,14 @@ python chainer-gogh.py -m nin -i input.png -s style.png -o output_dir -g GPU番 ### VGG実行サンプル ``` -python chainer-gogh.py -m vgg -i input.png -s style.png -o output_dir -g 0 --width 256 +python chainer-gogh.py -m vgg_chainer -i input.png -s style.png -o output_dir -g 0 --width 256 ``` ### モデルの指定方法 ``` -m nin ``` -のninを、vgg, googlenet, i2vに切り替えることが可能。 +のninを、vgg, vgg_chainer, googlenet, i2vに切り替えることが可能。 モデルファイルはディレクトリ直下に置いて、デフォルトの名前のまま変えないこと。 ### 複数枚同時生成 From 5f6cad64a6553e7a667e65b8322445ef5a98d8d0 Mon Sep 17 00:00:00 2001 From: Richard Calland Date: Mon, 13 Mar 2017 11:39:21 +0900 Subject: [PATCH 03/11] Update README.md Translation into english. Not completed yet --- README.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 78ddb75..b91ced1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # chainer-gogh ## Implementation of "A neural algorithm of Artistic style" (http://arxiv.org/abs/1508.06576) -## 解説記事: https://research.preferred.jp/2015/09/chainer-gogh/ +## Accompanying article: https://research.preferred.jp/2015/09/chainer-gogh/ @@ -26,16 +26,16 @@ -(VGG, lam=0.0075, after 5000 iteration) +(VGG, lam=0.0075, after 5000 iterations) ## Usage: -### Chainerをインストール +### Install Chainer ``` pip install chainer ``` -詳しくはhttps://github.com/pfnet/chainer +See https://github.com/pfnet/chainer for details. -### モデルをダウンロード +### Download the model * NIN https://gist.github.com/mavenlin/d802a5849de39225bcc6 お手軽。(`-m nin`) @@ -52,45 +52,45 @@ NIN並に軽く、ポテンシャルもあるはずだが、最適なパラメ VGGより軽く、二次元画像にとても強いはずだが、最適なパラメタがわかってない。(`-m i2v`) -### CPU実行 +### Run on CPU ``` python chainer-gogh.py -m nin -i input.png -s style.png -o output_dir -g -1 ``` -### GPU実行 +### Run on GPU ``` python chainer-gogh.py -m nin -i input.png -s style.png -o output_dir -g GPU番号 ``` -### VGG実行サンプル +### Stylize an image with VGG ``` python chainer-gogh.py -m vgg_chainer -i input.png -s style.png -o output_dir -g 0 --width 256 ``` -### モデルの指定方法 +### How to specify the model ``` -m nin ``` のninを、vgg, vgg_chainer, googlenet, i2vに切り替えることが可能。 モデルファイルはディレクトリ直下に置いて、デフォルトの名前のまま変えないこと。 -### 複数枚同時生成 -* まず、input.txtというファイル名で、以下の様なファイルを作る。 +### Generate multiple images simultaneously +* First, createa file called input.txt and list the input and output file names: ``` input0.png style0.png input1.png style1.png ... ``` -そして、chainer-gogh-multi.pyの方を実行 +then, run chainer-gogh-multi.py: ``` python chainer-gogh-multi.py -i input.txt ``` -VGGを使うときはGPUのメモリ不足に注意 +The VGG model uses a lot of GPU memory. -## パラメタについて -* `--lr`: 学習速度。生成の進捗が遅い時は大きめにする -* `--lam`: これを上げるとinput画像に近くなり、下げるとstyle画像に近くなる -* alpha, beta: 各層から伝播させる誤差にかかる係数。models.pyの中でハードコードされている。 +## About the parameters +* `--lr`: learning rate. Increase this when the generation progress is slow. +* `--lam`: increase the make the output image similar to the input, decrease to add more style. +* alpha, beta: coefficients relating to the error propagated from each layer. They are hard coded for each model. -## 注意 -* 現在のところ画像は正方形に近いほうがいいです +## Advice +* At the moment, using square images (e.g. 32x32) is best. From ea249be1d0b4d558797a7f65f1967d8aac5380e2 Mon Sep 17 00:00:00 2001 From: Richard Calland Date: Mon, 13 Mar 2017 12:24:47 +0900 Subject: [PATCH 04/11] Update README.md English translation complete. Not proofread by someone else yet. --- README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b91ced1..0cc5511 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # chainer-gogh -## Implementation of "A neural algorithm of Artistic style" (http://arxiv.org/abs/1508.06576) +## Implementation of "A neural algorithm of Artistic style" (http://arxiv.org/abs/1508.06576) in Chainer. ## Accompanying article: https://research.preferred.jp/2015/09/chainer-gogh/ @@ -35,22 +35,24 @@ pip install chainer ``` See https://github.com/pfnet/chainer for details. -### Download the model +### Download the model(s) +There are multiple models to chose from: * NIN https://gist.github.com/mavenlin/d802a5849de39225bcc6 -お手軽。(`-m nin`) +Simply specify: (`-m nin`) * VGG https://gist.github.com/ksimonyan/211839e770f7b538e2d8#file-readme-md -きれいな絵がかけるがとても重い。(`-m vgg`, `-m vgg_chainer`) -vgg_chainerではモデルのダウンロードの必要はなく、初回を除いて非常に高速でロードできるようになります(chainer 1.19以降で動作)。 +With VGG, it takes a long time to make good looking images. (`-m vgg`, `-m vgg_chainer`) + +After downloading and using the vgg_chainer model for the first time, all subsequent uses will load the model very fast.(functionality available in chainer 1.19 and above). * GoogLeNet https://github.com/BVLC/caffe/tree/master/models/bvlc_googlenet -NIN並に軽く、ポテンシャルもあるはずだが、最適なパラメタがわかっていない。(`-m googlenet`) +About the same as NIN, but there should be potential for good images. The optimum parameters are unknown. (`-m googlenet`) * illustration2vec http://illustration2vec.net/ (pre-trained model for tag prediction, version 2.0) -VGGより軽く、二次元画像にとても強いはずだが、最適なパラメタがわかってない。(`-m i2v`) +Lightweight compared to VGG, should be good for illustrations/anime drawings. Optimal parameters are unknown. (`-m i2v`) ### Run on CPU ``` @@ -59,7 +61,7 @@ python chainer-gogh.py -m nin -i input.png -s style.png -o output_dir -g -1 ### Run on GPU ``` -python chainer-gogh.py -m nin -i input.png -s style.png -o output_dir -g GPU番号 +python chainer-gogh.py -m nin -i input.png -s style.png -o output_dir -g ``` ### Stylize an image with VGG @@ -71,8 +73,7 @@ python chainer-gogh.py -m vgg_chainer -i input.png -s style.png -o output_dir -g ``` -m nin ``` -のninを、vgg, vgg_chainer, googlenet, i2vに切り替えることが可能。 -モデルファイルはディレクトリ直下に置いて、デフォルトの名前のまま変えないこと。 +It is possible to change from nin to vgg, vgg_chainer, googlenet or i2v. To do this, put the model file in the working directory, keeping the default file name. ### Generate multiple images simultaneously * First, createa file called input.txt and list the input and output file names: @@ -85,7 +86,7 @@ then, run chainer-gogh-multi.py: ``` python chainer-gogh-multi.py -i input.txt ``` -The VGG model uses a lot of GPU memory. +The VGG model uses a lot of GPU memory, be careful! ## About the parameters * `--lr`: learning rate. Increase this when the generation progress is slow. From 3d712ddaed4d19573eef7fed34e72e1b7a6457d9 Mon Sep 17 00:00:00 2001 From: Richard Calland Date: Mon, 13 Mar 2017 12:36:40 +0900 Subject: [PATCH 05/11] Update README.md fix typo at line 93 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0cc5511..7976fe1 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ The VGG model uses a lot of GPU memory, be careful! ## About the parameters * `--lr`: learning rate. Increase this when the generation progress is slow. -* `--lam`: increase the make the output image similar to the input, decrease to add more style. +* `--lam`: increase to make the output image similar to the input, decrease to add more style. * alpha, beta: coefficients relating to the error propagated from each layer. They are hard coded for each model. ## Advice From 3ee76e82e6f7c9cd4ea8ff62f0dd1646b174014c Mon Sep 17 00:00:00 2001 From: Richard Calland Date: Mon, 13 Mar 2017 13:03:47 +0900 Subject: [PATCH 06/11] Update README.md changed the recommended image size from 32x32 to 256x256 --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7976fe1..90768ea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # chainer-gogh - -## Implementation of "A neural algorithm of Artistic style" (http://arxiv.org/abs/1508.06576) in Chainer. +Implementation of "A neural algorithm of Artistic style" (http://arxiv.org/abs/1508.06576) in Chainer. ## Accompanying article: https://research.preferred.jp/2015/09/chainer-gogh/ @@ -94,4 +93,4 @@ The VGG model uses a lot of GPU memory, be careful! * alpha, beta: coefficients relating to the error propagated from each layer. They are hard coded for each model. ## Advice -* At the moment, using square images (e.g. 32x32) is best. +* At the moment, using square images (e.g. 256x256) is best. From 6e154a96d20b95970ab6dd5c15720dd86087d445 Mon Sep 17 00:00:00 2001 From: Richard Calland Date: Mon, 13 Mar 2017 14:39:13 +0900 Subject: [PATCH 07/11] Create README-ja.md --- README-ja.md | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 README-ja.md diff --git a/README-ja.md b/README-ja.md new file mode 100644 index 0000000..78ddb75 --- /dev/null +++ b/README-ja.md @@ -0,0 +1,96 @@ +# chainer-gogh + +## Implementation of "A neural algorithm of Artistic style" (http://arxiv.org/abs/1508.06576) +## 解説記事: https://research.preferred.jp/2015/09/chainer-gogh/ + + + + + + + + + + + + + + + + + + + + + + + + +(VGG, lam=0.0075, after 5000 iteration) + +## Usage: +### Chainerをインストール +``` +pip install chainer +``` +詳しくはhttps://github.com/pfnet/chainer + +### モデルをダウンロード +* NIN https://gist.github.com/mavenlin/d802a5849de39225bcc6 + +お手軽。(`-m nin`) +* VGG https://gist.github.com/ksimonyan/211839e770f7b538e2d8#file-readme-md + +きれいな絵がかけるがとても重い。(`-m vgg`, `-m vgg_chainer`) +vgg_chainerではモデルのダウンロードの必要はなく、初回を除いて非常に高速でロードできるようになります(chainer 1.19以降で動作)。 + +* GoogLeNet https://github.com/BVLC/caffe/tree/master/models/bvlc_googlenet + +NIN並に軽く、ポテンシャルもあるはずだが、最適なパラメタがわかっていない。(`-m googlenet`) + +* illustration2vec http://illustration2vec.net/ (pre-trained model for tag prediction, version 2.0) + +VGGより軽く、二次元画像にとても強いはずだが、最適なパラメタがわかってない。(`-m i2v`) + +### CPU実行 +``` +python chainer-gogh.py -m nin -i input.png -s style.png -o output_dir -g -1 +``` + +### GPU実行 +``` +python chainer-gogh.py -m nin -i input.png -s style.png -o output_dir -g GPU番号 +``` + +### VGG実行サンプル +``` +python chainer-gogh.py -m vgg_chainer -i input.png -s style.png -o output_dir -g 0 --width 256 +``` + +### モデルの指定方法 +``` +-m nin +``` +のninを、vgg, vgg_chainer, googlenet, i2vに切り替えることが可能。 +モデルファイルはディレクトリ直下に置いて、デフォルトの名前のまま変えないこと。 + +### 複数枚同時生成 +* まず、input.txtというファイル名で、以下の様なファイルを作る。 +``` +input0.png style0.png +input1.png style1.png +... +``` +そして、chainer-gogh-multi.pyの方を実行 +``` +python chainer-gogh-multi.py -i input.txt +``` +VGGを使うときはGPUのメモリ不足に注意 + +## パラメタについて +* `--lr`: 学習速度。生成の進捗が遅い時は大きめにする +* `--lam`: これを上げるとinput画像に近くなり、下げるとstyle画像に近くなる +* alpha, beta: 各層から伝播させる誤差にかかる係数。models.pyの中でハードコードされている。 + +## 注意 +* 現在のところ画像は正方形に近いほうがいいです From efcfd3ed1240a8df41e49e3c5052dbea2fe53b7b Mon Sep 17 00:00:00 2001 From: Richard Calland Date: Mon, 13 Mar 2017 14:40:47 +0900 Subject: [PATCH 08/11] Update README.md Added link to original japanese version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 90768ea..f2ccdd1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # chainer-gogh -Implementation of "A neural algorithm of Artistic style" (http://arxiv.org/abs/1508.06576) in Chainer. +Implementation of "A neural algorithm of Artistic style" (http://arxiv.org/abs/1508.06576) in Chainer. The Japanese readme can be found [here](README-ja.md). ## Accompanying article: https://research.preferred.jp/2015/09/chainer-gogh/ From b8f6ba25c0d84c569cfe30fc37efecdd58d23e1d Mon Sep 17 00:00:00 2001 From: Richard Calland Date: Mon, 13 Mar 2017 15:30:37 +0900 Subject: [PATCH 09/11] Update README.md fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f2ccdd1..e5d08d1 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ python chainer-gogh.py -m vgg_chainer -i input.png -s style.png -o output_dir -g It is possible to change from nin to vgg, vgg_chainer, googlenet or i2v. To do this, put the model file in the working directory, keeping the default file name. ### Generate multiple images simultaneously -* First, createa file called input.txt and list the input and output file names: +* First, create a file called input.txt and list the input and output file names: ``` input0.png style0.png input1.png style1.png From 2ea7681733ee3b19753b69b566d9d97cef9f345c Mon Sep 17 00:00:00 2001 From: Yuto Tagashira Date: Sun, 19 Aug 2018 17:36:38 +0900 Subject: [PATCH 10/11] add requirements for dependency --- requirements.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f700bfe --- /dev/null +++ b/requirements.txt @@ -0,0 +1,7 @@ +chainer==1.20.0 +filelock==3.0.4 +nose==1.3.7 +numpy==1.15.0 +Pillow==5.2.0 +protobuf==3.6.1 +six==1.11.0 From 4c9e6483e97bc0b758eb51cddc65e0173b7ed982 Mon Sep 17 00:00:00 2001 From: Yuto Tagashira Date: Sun, 19 Aug 2018 17:44:36 +0900 Subject: [PATCH 11/11] update README(-ja).md --- README-ja.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README-ja.md b/README-ja.md index 78ddb75..68af3d8 100644 --- a/README-ja.md +++ b/README-ja.md @@ -31,7 +31,7 @@ ## Usage: ### Chainerをインストール ``` -pip install chainer +pip install -r requirements.txt ``` 詳しくはhttps://github.com/pfnet/chainer diff --git a/README.md b/README.md index e5d08d1..fb835fa 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Implementation of "A neural algorithm of Artistic style" (http://arxiv.org/abs/1 ## Usage: ### Install Chainer ``` -pip install chainer +pip install -r requirements.txt ``` See https://github.com/pfnet/chainer for details.