Deep Learning

提供:kuhalaboWiki
(版間での差分)
移動: 案内, 検索
(Chainer fast Neuralstyle)
(PaintsChainer)
 
(1人の利用者による、間の126版が非表示)
1行: 1行:
== 環境設定 ==
+
== PaintsChainer ==
MacOSのLinuxで。
+
 
 +
https://github.com/pfnet/PaintsChainer
 +
 
 +
https://qiita.com/ikeyasu/items/6c1ebed07b281281b1f6
 +
 
 +
== Generative Music ==
 +
;AdaIN
 +
:styleGANに使われている。
 +
 
 +
深層学習は、精製モデルと認識も出るの両輪で発展。生成モデル制御は両方にかかわる。
 +
 
 +
;VAE
 +
 
 +
== memo ==
 +
 
 +
 
 +
=== w3 ===
 +
 
 +
CentOS Linux release 7.5.1804 (Core)
 +
 
 +
=== www ===
 +
 
 +
CentOS release 6.8 (Final)
 +
 
 +
 
 +
* [[Neural Networks]]
 +
* はじめてのAI https://www.udemy.com/google-jp-ai/
 +
**How Google does Machine Learning
 +
**Machine Learning Crash Course
 +
**Cloud AI サービス
 +
* The Building Blocks of Interpretability https://distill.pub/2018/building-blocks/
 +
 
 +
== MacOSX ==
 +
;command line developer toolsのインストール
 +
<pre>
 +
$ xcode-select --install
 +
</pre>
  
 
=== 開発環境整備 ===
 
=== 開発環境整備 ===
 +
;homebrew
 +
Homebrew をダウンロード・インストール
 +
http://brew.sh/index_ja.html
  
* homebrew
 
 
* pnenv
 
* pnenv
 
 
* Phthon
 
* Phthon
 
** anaconda2
 
** anaconda2
 
** anaconda3
 
** anaconda3
 
 
* pip
 
* pip
  
Python3 とpip3のインストール
+
=== oF ===
 +
;openFrameworks
 +
https://openframeworks.cc/setup/linux-install/
 +
 
 +
== Ubuntu ==
 +
 
 +
;Python3 とpip3のインストール
 
<pre>
 
<pre>
 
sudo apt install python3 python3-pip
 
sudo apt install python3 python3-pip
 
</pre>
 
</pre>
  
 
+
;PILライブラリのインストール
== Ubuntu ==
+
<pre>
 +
sudo pip install pillow
 +
</pre>
  
 
=== VNC ===
 
=== VNC ===
39行: 83行:
 
* ${pass}:${user}のパスワード
 
* ${pass}:${user}のパスワード
  
== github ==
+
dl-box 192.168.11.3
 +
 
 +
=== アプリ自動起動 ===
  
プロキシ―環境にある場合は、プロキシ―サーバーをスルーする必要がある。
+
* sessionにて指定する。
 +
 
 +
=== 自動シャットダウン ===
 +
 
 +
;cronを使用する。
 +
 
 +
エディターを開く。
 
<pre>
 
<pre>
git config --global http.proxy http://proxy-a.t-kougei.ac.jp:8080
+
$sudo crontab -e
git config --global https.proxy https://proxy-a.t-kougei.ac.jp:8080
+
 
</pre>
 
</pre>
  
通常のプロキシーのない環境で作業する場合、コンソールで
+
一番最後の行に以下の記述を追加する。
 
<pre>
 
<pre>
git config --global --unset http.proxy proxy.hogehoge.ac.jp
+
30 22 * * * /sbin/shutdown -h now
git config --global --unset https.proxy proxy.hogehoge.ac.jp
+
 
</pre>
 
</pre>
とする。
+
毎日22:30にシャットダウンするという意味。
 +
 
 +
保存して、エディターを閉じる。
 +
* 保存 [Ctrl] + o
 +
* 閉じる [Ctrl] + x
  
現在の設定を確認するには、コンソールで、
+
設定を確認する。
 
<pre>
 
<pre>
git config --list
+
$crontab -l
 
</pre>
 
</pre>
とする。
 
  
== Chainer ==
+
;端末の起動
MacOSで
+
:Alt+Cntl+T (Command+option+T)
  
* CUDA
+
== Python ==
*opencv
+
 
*deel
+
== Virtualbox ==
* CSLAIER  http://localhost:8080
+
Oracle VM VirtualBoxで仮想マシン上にUbuntuを入れる。
 +
https://www.virtualbox.org/
 +
 
 +
VirtualBoxで共有フォルダにアクセス権限がないとのエラーが出る場合は、以下の通り。
 
<pre>
 
<pre>
$ ./run.sh
+
sudo gpasswd -a ユーザ名 vboxsf
 
</pre>
 
</pre>
  
Chainerのインストール
+
Ubuntuのアップデート
 
<pre>
 
<pre>
pip3 install chainer
+
sudo apt update
 
</pre>
 
</pre>
  
 +
=== UbuntuAI ===
 +
*仮想マシンイメージ:UbuntuAIのダウンロード https://book.impress.co.jp/books/1116101162
 +
*タイプ:Linux
 +
*バージョン:Ubuntu(64bit)
 +
*メモリーサイズ:2048MB
 +
*ハードディスク:すでにある仮想ハードディスクを使用する「UbuntuAI.vdi」
  
=== 仕様の変更 ===
+
== 画像処理 ==
 +
Pythonでの画像処理
 +
* Numpy 高速数値演算
 +
* Pillow 画像処理
 +
* OpenCV コンピュータビジョン
  
chainer.functionsがchainer.linksに変更
+
OpenCVではカラー画像はBGRで表す歴史的背景 [https://www.learnopencv.com/why-does-opencv-use-bgr-color-format/ Why does OpenCV use BGR color format ?]
 +
 
 +
BGRからRGBへの変換
 
<pre>
 
<pre>
import chainer
+
img_rgb = img_bgr[:,:,::-1].copy()
from chainer.dataset import convert
+
from chainer import cuda
+
import chainer.functions as F
+
#import chainer.links as F
+
import chainer.link
+
import chainer.links
+
#from chainer.functions import caffe
+
from chainer.links import caffe
+
from chainer.links.caffe import CaffeFunction
+
from chainer import Variable, optimizers, Chain, cuda
+
 
</pre>
 
</pre>
  
 +
RGBからBGRへの変換
 +
<pre>
 +
img_bgr = img_rgb[:,:,::-1].copy()
 +
</pre>
 +
 +
Pythonのスライス「第1, 2次元目はそのままで、第3次元目は逆方向に並べたもの」
 +
 +
 +
PythonのopenCVでフルスクリーンにする方法
 +
<pre>
 +
cv2.namedWindow("screen", cv2.WINDOW_NORMAL)
 +
cv2.setWindowProperty('screen', cv2.WND_PROP_FULLSCREEN, 1)
 +
cv2.imshow('screen', img)
 +
</pre>
 +
フルスクリーンを解除するには
 +
<pre>
 +
cv2.setWindowProperty('screen', cv2.WND_PROP_FULLSCREEN, 0)
 +
</pre>
 +
 +
== Chainer fast Neuralstyle ==
 +
 +
;論文
 +
: Justin Johnson, Alexandre Alahi, Li Fei-Fei, "Perceptual Losses for Real-Time Style Transfer and Super-Resolution"
 +
: https://arxiv.org/abs/1603.08155
 +
 +
;実装
 +
* https://github.com/yusuketomoto/chainer-fast-neuralstyle
 +
* https://github.com/gafr/chainer-fast-neuralstyle-models
 +
* https://github.com/gafr/chainer-fast-neuralstyle-video
 +
* https://github.com/toriniku000/prox2017_neural_video
 +
* https://github.com/jcjohnson/fast-neural-style
 +
 +
;Training画像データ
 +
*http://cocodataset.org/#home
 +
**http://msvocds.blob.core.windows.net/coco2014/train2014.zip
 +
 +
スタイル学習(モデルの生成)
 +
* -sでスタイル画像
 +
* -dでダウンロードしてきた画像集のフォルダを指定
 +
* -rでリジューム
 +
<pre>
 +
python train.py -s スタイル画像 -d 画像集フォルダ -r
 +
python train.py -s スタイル画像 -d train2014 -o 生成モデル名 -r
 +
</pre>
 +
 +
;train.pyの修正
 +
*https://github.com/yusuketomoto/chainer-fast-neuralstyle/issues/40
 +
 +
<pre>
 +
#    image = image.crop(((w-size)*0.5, (h-size)*0.5, (w+size)*0.5, (h+size)*0.5))
 +
    image = image.crop((int((w-size)*0.5), int((h-size)*0.5), int((w+size)*0.5), int((h+size)*0.5)))
 +
</pre>
 +
 +
クローン
 +
<pre>
 +
git clone https://github.com/yusuketomoto/chainer-fast-neuralstyle.git
 +
</pre>
 +
 +
VGGのダウンロード。
 +
<pre>
 +
wget http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_16_layers.caffemodel
 +
</pre>
 +
 +
chainer用に変換。
 +
<pre>
 +
python create_chainer_model.py
 +
</pre>
 +
 +
 +
画風変換
 +
<pre>
 +
python generate.py sample_images/コンテンツ元画像.jpg -m models/学習モデル.model -o sample_images/出力画像.jpg
 +
</pre>
 +
 +
* MacBook Pro CPU 3.3GHz Intel Core i7, 16GB, intel iris Graphics 550 1536MB : 15sec
 +
* GeForce GTX 1080 Ti (CNMeM is enabled with initial size: 50.0% of memory, cuDNN 5105) : 0.856794118881 sec
 +
* Xeon E5-1620v4 4core/8thread 3.5GHz, 64GB : 8.52293109894 sec
 +
 +
== CubistMirror ==
 +
oFでUbuntuのchainerを動かす。
 +
 +
https://openframeworks.cc/
 +
 +
LinuxでのoF
 +
<pre>
 +
make
 +
make run
 +
</pre>
 +
 +
https://github.com/genekogan/CubistMirror
 +
 +
*oF0.10では,Pocoライブラリーが機能しない。
 +
**v0.10では,PocoはAddonになった。v0.9以前は,本体に入っていた模様。
 +
* QuickTime/QuickTime.h not found,には以下のものを使用。
 +
** https://openframeworks.cc/versions/v0.9.4_RC1/
 +
 +
;外部カメラを接続する場合
 +
<pre>
 +
// ofApp.h
 +
    ofVideoGrabber grab;
 +
 +
//ofApp.cpp setup()
 +
    // set up camera
 +
    ofSetLogLevel(OF_LOG_VERBOSE);
 +
    grab.setVerbose(true);
 +
    grab.listDevices();   
 +
    grab.setDeviceID(1);// camera ID set 
 +
</pre>
  
 
== A neural algorithm of Artistic style ==
 
== A neural algorithm of Artistic style ==
99行: 265行:
 
http://arxiv.org/abs/1508.06576
 
http://arxiv.org/abs/1508.06576
  
 +
A Neural Algorithm of Artistic Style
 +
 +
Leon A. Gatys, Alexander S. Ecker, Matthias Bethge
 +
(Submitted on 26 Aug 2015 (v1), last revised 2 Sep 2015 (this version, v2))
  
 
== chainer-gogh ==
 
== chainer-gogh ==
  
 +
画風を変換するアルゴリズム(Preferred Networks(PFN)松元叡一氏)
 
https://research.preferred.jp/2015/09/chainer-gogh/
 
https://research.preferred.jp/2015/09/chainer-gogh/
  
122行: 293行:
 
caffemodel: VGG_ILSVRC_16_layers
 
caffemodel: VGG_ILSVRC_16_layers
 
<pre>
 
<pre>
chttp://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_16_layers.caffemodel
+
wget http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_16_layers.caffemodel
 
</pre>
 
</pre>
 
処理は重いが、描画が綺麗。
 
処理は重いが、描画が綺麗。
146行: 317行:
 
*コンテンツ画像は 500-1000ピクセル程度のサイズに
 
*コンテンツ画像は 500-1000ピクセル程度のサイズに
 
*スタイル画像も 500-1000ピクセル程度のサイズに
 
*スタイル画像も 500-1000ピクセル程度のサイズに
*オプションの値
+
;オプションの値
 
<pre>
 
<pre>
 
parser = argparse.ArgumentParser(
 
parser = argparse.ArgumentParser(
170行: 341行:
 
args = parser.parse_args()
 
args = parser.parse_args()
 
</pre>
 
</pre>
 +
 +
 +
=== 仕様の変更 ===
 +
 +
*chainer.functionsがchainer.linksに変更
 +
<pre>
 +
import chainer
 +
from chainer.dataset import convert
 +
from chainer import cuda
 +
import chainer.functions as F
 +
#import chainer.links as F
 +
import chainer.link
 +
import chainer.links
 +
#from chainer.functions import caffe
 +
from chainer.links import caffe
 +
from chainer.links.caffe import CaffeFunction
 +
from chainer import Variable, optimizers, Chain, cuda
 +
</pre>
 +
 +
*volatileとtrainオプションがなくなったので、*.pyソース内の引数を削除
 +
  
 
*GPU使用時のエラー
 
*GPU使用時のエラー
184行: 376行:
 
これは、指定したGPUがないか使えないということ。ドライバーをインストールしなおしたら、解決した。
 
これは、指定したGPUがないか使えないということ。ドライバーをインストールしなおしたら、解決した。
  
== Chainer fast Neuralstyle ==
+
== neuralart TensorFlow ==
  
https://github.com/yusuketomoto/chainer-fast-neuralstyle
+
https://github.com/ckmarkoh/neuralart_tensorflow
  
https://github.com/gafr/chainer-fast-neuralstyle-models
+
== github ==
  
https://github.com/gafr/chainer-fast-neuralstyle-video
+
プロキシ―環境にある場合は、プロキシ―サーバーをスルーする必要がある。
 
+
<pre>
http://msvocds.blob.core.windows.net/coco2014/train2014.zip
+
git config --global http.proxy http://proxy-a.t-kougei.ac.jp:8080
 
+
git config --global https.proxy https://proxy-a.t-kougei.ac.jp:8080
=== CubistMirror ===
+
</pre>
https://github.com/genekogan/CubistMirror
+
 
+
*oF0.10では,Pocoライブラリーが機能しない。
+
**v0.10では,PocoはAddonになった。v0.9以前は,本体に入っていたよう。
+
* QuickTime/QuickTime.h not found,には以下のものを使用。
+
** https://openframeworks.cc/versions/v0.9.4_RC1/
+
 
+
;学習
+
* -sでスタイル画像
+
* -dでダウンロードしてきた画像集のフォルダを指定
+
* -rでリジューム
+
  
 +
通常のプロキシーのない環境で作業する場合、コンソールで
 
<pre>
 
<pre>
python train.py -s スタイル画像 -d 画像集フォルダ -r
+
git config --global --unset http.proxy proxy.hogehoge.ac.jp
 +
git config --global --unset https.proxy proxy.hogehoge.ac.jp
 
</pre>
 
</pre>
 +
とする。
  
 
+
現在の設定を確認するには、コンソールで、
;変換
+
 
<pre>
 
<pre>
python generate.py sample_images/コンテンツ元画像.jpg -m models/学習モデル.model -o sample_images/出力画像.jpg
+
git config --list
 
</pre>
 
</pre>
 +
とする。
  
== neuralart TensorFlow ==
+
== Chainer ==
 
+
MacOSで
https://github.com/ckmarkoh/neuralart_tensorflow
+
 
+
  
 
+
* CUDA
 
+
*opencv
== Virtualbox ==
+
*deel
Oracle VM VirtualBoxで仮想マシン上にUbuntuを入れる。
+
* CSLAIER  http://localhost:8080
https://www.virtualbox.org/
+
 
+
仮想マシンイメージUbuntuAIのダウンロード
+
https://book.impress.co.jp/books/1116101162
+
 
+
VirtualBoxで共有フォルダにアクセス権限がないとのエラーが出る場合は、以下の通り。
+
 
<pre>
 
<pre>
sudo gpasswd -a ユーザ名 vboxsf
+
$ ./run.sh
 
</pre>
 
</pre>
  
Ubuntuのアップデート
+
Chainerのインストール
 
<pre>
 
<pre>
sudo apt update
+
pip3 install chainer
 
</pre>
 
</pre>
  
 
== TensorFlow ==
 
== TensorFlow ==
 +
 +
== PyTorch ==
 +
 +
https://pytorch.org/tutorials/advanced/neural_style_tutorial.html
  
 
== Work Station ==
 
== Work Station ==
251行: 431行:
 
http://www.univpc.com/product_list/cpu/74/99
 
http://www.univpc.com/product_list/cpu/74/99
  
 +
ノート型
 +
https://www.pc-koubou.jp/pc/deeplearning_pc.php?pre=cmm_hnv_019
  
 
== 参考 ==
 
== 参考 ==
チームラボの勉強会
 
  
* https://www.slideshare.net/yamaryox/deep-learning-2016516
+
=== 絵画風動画変換 ===
* https://www.slideshare.net/yamaryox/artistic-style-transfer-for-videos
+
箱根にあるとある水車小屋 https://youtu.be/3MwTQJrDCeo
 +
 
 +
ローマの休日 https://youtu.be/F5RTxOr0_Cw
 +
 
 +
=== 物体検出 ===
 +
 
 +
http://ai-coordinator.jp/category/object-detection
 +
 
 +
 
 +
=== AI Artistic Neuro Painter ===
 +
 
 +
http://www.kuhalabo.net/aipaint/
 +
 
 +
http://www.kuhalabo.net/aipaint/iframe.html
 +
 
 +
 
 +
[[Category:研究]]

2021年4月10日 (土) 06:48時点における最新版

目次

[編集] PaintsChainer

https://github.com/pfnet/PaintsChainer

https://qiita.com/ikeyasu/items/6c1ebed07b281281b1f6

[編集] Generative Music

AdaIN
styleGANに使われている。

深層学習は、精製モデルと認識も出るの両輪で発展。生成モデル制御は両方にかかわる。

VAE

[編集] memo

[編集] w3

CentOS Linux release 7.5.1804 (Core)

[編集] www

CentOS release 6.8 (Final)


[編集] MacOSX

command line developer toolsのインストール
$ xcode-select --install

[編集] 開発環境整備

homebrew

Homebrew をダウンロード・インストール http://brew.sh/index_ja.html

  • pnenv
  • Phthon
    • anaconda2
    • anaconda3
  • pip

[編集] oF

openFrameworks

https://openframeworks.cc/setup/linux-install/

[編集] Ubuntu

Python3 とpip3のインストール
sudo apt install python3 python3-pip
PILライブラリのインストール
sudo pip install pillow

[編集] VNC

Ubuntuの標準VNCクライアントRemminaリモートデスクトップクライアント

[編集] wget

Proxy経由でwgetを実行する。

~/.wgetrcに以下を記述。
http_proxy=http://${xxx.xxx.xxx.xxx}:${pp}/
proxy_user=${user}
proxy_password=${pass}
  • ${xxx.xxx.xxx.xxx}:プロキシサーバのIPアドレス
  • ${pp}:プロキシに利用するポート(基本的にはhttpのポート番号80を指定)
  • ${user}:プロキシとして利用するユーザ
  • ${pass}:${user}のパスワード

dl-box 192.168.11.3

[編集] アプリ自動起動

  • sessionにて指定する。

[編集] 自動シャットダウン

cronを使用する。

エディターを開く。

$sudo crontab -e

一番最後の行に以下の記述を追加する。

30 22 * * * /sbin/shutdown -h now

毎日22:30にシャットダウンするという意味。

保存して、エディターを閉じる。

  • 保存 [Ctrl] + o
  • 閉じる [Ctrl] + x

設定を確認する。

$crontab -l
端末の起動
Alt+Cntl+T (Command+option+T)

[編集] Python

[編集] Virtualbox

Oracle VM VirtualBoxで仮想マシン上にUbuntuを入れる。 https://www.virtualbox.org/

VirtualBoxで共有フォルダにアクセス権限がないとのエラーが出る場合は、以下の通り。

sudo gpasswd -a ユーザ名 vboxsf

Ubuntuのアップデート

sudo apt update

[編集] UbuntuAI

  • 仮想マシンイメージ:UbuntuAIのダウンロード https://book.impress.co.jp/books/1116101162
  • タイプ:Linux
  • バージョン:Ubuntu(64bit)
  • メモリーサイズ:2048MB
  • ハードディスク:すでにある仮想ハードディスクを使用する「UbuntuAI.vdi」

[編集] 画像処理

Pythonでの画像処理

  • Numpy 高速数値演算
  • Pillow 画像処理
  • OpenCV コンピュータビジョン

OpenCVではカラー画像はBGRで表す歴史的背景 Why does OpenCV use BGR color format ?

BGRからRGBへの変換

img_rgb = img_bgr[:,:,::-1].copy()

RGBからBGRへの変換

img_bgr = img_rgb[:,:,::-1].copy()

Pythonのスライス「第1, 2次元目はそのままで、第3次元目は逆方向に並べたもの」


PythonのopenCVでフルスクリーンにする方法

cv2.namedWindow("screen", cv2.WINDOW_NORMAL)
cv2.setWindowProperty('screen', cv2.WND_PROP_FULLSCREEN, 1)
cv2.imshow('screen', img)

フルスクリーンを解除するには

cv2.setWindowProperty('screen', cv2.WND_PROP_FULLSCREEN, 0)

[編集] Chainer fast Neuralstyle

論文
Justin Johnson, Alexandre Alahi, Li Fei-Fei, "Perceptual Losses for Real-Time Style Transfer and Super-Resolution"
https://arxiv.org/abs/1603.08155
実装
Training画像データ

スタイル学習(モデルの生成)

  • -sでスタイル画像
  • -dでダウンロードしてきた画像集のフォルダを指定
  • -rでリジューム
python train.py -s スタイル画像 -d 画像集フォルダ -r
python train.py -s スタイル画像 -d train2014 -o 生成モデル名 -r
train.pyの修正
#    image = image.crop(((w-size)*0.5, (h-size)*0.5, (w+size)*0.5, (h+size)*0.5))
    image = image.crop((int((w-size)*0.5), int((h-size)*0.5), int((w+size)*0.5), int((h+size)*0.5)))

クローン

git clone https://github.com/yusuketomoto/chainer-fast-neuralstyle.git

VGGのダウンロード。

wget http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_16_layers.caffemodel

chainer用に変換。

python create_chainer_model.py


画風変換

python generate.py sample_images/コンテンツ元画像.jpg -m models/学習モデル.model -o sample_images/出力画像.jpg
  • MacBook Pro CPU 3.3GHz Intel Core i7, 16GB, intel iris Graphics 550 1536MB : 15sec
  • GeForce GTX 1080 Ti (CNMeM is enabled with initial size: 50.0% of memory, cuDNN 5105) : 0.856794118881 sec
  • Xeon E5-1620v4 4core/8thread 3.5GHz, 64GB : 8.52293109894 sec

[編集] CubistMirror

oFでUbuntuのchainerを動かす。

https://openframeworks.cc/

LinuxでのoF

make
make run

https://github.com/genekogan/CubistMirror

  • oF0.10では,Pocoライブラリーが機能しない。
    • v0.10では,PocoはAddonになった。v0.9以前は,本体に入っていた模様。
  • QuickTime/QuickTime.h not found,には以下のものを使用。
外部カメラを接続する場合
 // ofApp.h
    ofVideoGrabber grab;

//ofApp.cpp setup()
    // set up camera
    ofSetLogLevel(OF_LOG_VERBOSE); 
    grab.setVerbose(true);
    grab.listDevices();    
    grab.setDeviceID(1);// camera ID set   

[編集] A neural algorithm of Artistic style

http://arxiv.org/abs/1508.06576

A Neural Algorithm of Artistic Style

Leon A. Gatys, Alexander S. Ecker, Matthias Bethge (Submitted on 26 Aug 2015 (v1), last revised 2 Sep 2015 (this version, v2))

[編集] chainer-gogh

画風を変換するアルゴリズム(Preferred Networks(PFN)松元叡一氏) https://research.preferred.jp/2015/09/chainer-gogh/

chainer-goghのインストール https://github.com/mattya/chainer-gogh.git

git clone https://github.com/mattya/chainer-gogh.git

学習済みモデルのダウンロード

  • nin
wget https://www.dropbox.com/s/0cidxafrb2wuwxw/nin_imagenet.caffemodel

上記のコマンドとシェルスクリプトで。

source ~/dlmodel.sh
  • vgg

caffemodel: VGG_ILSVRC_16_layers

wget http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_16_layers.caffemodel

処理は重いが、描画が綺麗。


chainer-gogh.pyの書式

python3 chainer-gogh.py [-m MODEL] -i CONTENS.jpg -s STYLE.jpg -o OUTPUT_DIR -g GPU_NUM [--width SIZE]

chainer-gogh.pyの実行例

python3 chainer-gogh.py -i sample_images/contents8.jpg -s sample_images/style.jpg -o save_images -g -1


例)元画像の重みを上げ、横幅460、イテレーション8000まで実行して作成する場合。

python chainer-gogh.py -m nin -i contents.png -s style.png -o output -g -1 --lam 0.8 --width 460 --iter 8000
  • 最終的な画像サイズは512*512ピクセル以下に縮小
  • コンテンツ画像はJPG または PNG
  • コンテンツ画像は 500-1000ピクセル程度のサイズに
  • スタイル画像も 500-1000ピクセル程度のサイズに
オプションの値
parser = argparse.ArgumentParser(
    description='A Neural Algorithm of Artistic Style')
parser.add_argument('--model', '-m', default='nin',
                    help='model file (nin, vgg, i2v, googlenet)')
parser.add_argument('--orig_img', '-i', default='orig.png',
                    help='Original image')
parser.add_argument('--style_img', '-s', default='style.png',
                    help='Style image')
parser.add_argument('--out_dir', '-o', default='output',
                    help='Output directory')
parser.add_argument('--gpu', '-g', default=-1, type=int,
                    help='GPU ID (negative value indicates CPU)')
parser.add_argument('--iter', default=5000, type=int,
                    help='number of iteration')
parser.add_argument('--lr', default=4.0, type=float,
                    help='learning rate')
parser.add_argument('--lam', default=0.005, type=float,
                    help='original image weight / style weight ratio')
parser.add_argument('--width', '-w', default=435, type=int,
                    help='image width, height')
args = parser.parse_args()


[編集] 仕様の変更

  • chainer.functionsがchainer.linksに変更
import chainer
from chainer.dataset import convert
from chainer import cuda
import chainer.functions as F
#import chainer.links as F
import chainer.link
import chainer.links
#from chainer.functions import caffe
from chainer.links import caffe
from chainer.links.caffe import CaffeFunction
from chainer import Variable, optimizers, Chain, cuda
  • volatileとtrainオプションがなくなったので、*.pyソース内の引数を削除


  • GPU使用時のエラー
Traceback (most recent call last):
  File "chainer-gogh.py", line 179, in <module>
    cuda.get_device(args.gpu).use()
  File "cupy/cuda/device.pyx", line 98, in cupy.cuda.device.Device.use
  File "cupy/cuda/device.pyx", line 104, in cupy.cuda.device.Device.use
  File "cupy/cuda/runtime.pyx", line 185, in cupy.cuda.runtime.setDevice
  File "cupy/cuda/runtime.pyx", line 137, in cupy.cuda.runtime.check_status
cupy.cuda.runtime.CUDARuntimeError: cudaErrorUnknown: unknown error

これは、指定したGPUがないか使えないということ。ドライバーをインストールしなおしたら、解決した。

[編集] neuralart TensorFlow

https://github.com/ckmarkoh/neuralart_tensorflow

[編集] github

プロキシ―環境にある場合は、プロキシ―サーバーをスルーする必要がある。

git config --global http.proxy http://proxy-a.t-kougei.ac.jp:8080
git config --global https.proxy https://proxy-a.t-kougei.ac.jp:8080

通常のプロキシーのない環境で作業する場合、コンソールで

git config --global --unset http.proxy proxy.hogehoge.ac.jp
git config --global --unset https.proxy proxy.hogehoge.ac.jp

とする。

現在の設定を確認するには、コンソールで、

git config --list

とする。

[編集] Chainer

MacOSで

$ ./run.sh

Chainerのインストール

pip3 install chainer

[編集] TensorFlow

[編集] PyTorch

https://pytorch.org/tutorials/advanced/neural_style_tutorial.html

[編集] Work Station

NVIDIA Digits https://developer.nvidia.com/digits

大学生協対応PC http://www.univpc.com/product_list/cpu/74/99

ノート型 https://www.pc-koubou.jp/pc/deeplearning_pc.php?pre=cmm_hnv_019

[編集] 参考

[編集] 絵画風動画変換

箱根にあるとある水車小屋 https://youtu.be/3MwTQJrDCeo

ローマの休日 https://youtu.be/F5RTxOr0_Cw

[編集] 物体検出

http://ai-coordinator.jp/category/object-detection


[編集] AI Artistic Neuro Painter

http://www.kuhalabo.net/aipaint/

http://www.kuhalabo.net/aipaint/iframe.html

個人用ツール
名前空間

変種
操作
案内
ツールボックス