2017/07/02 chainerã®ãã¼ã¸ã§ã³ä¿®æ£ 1.6 -> 1.8.1 2016/12/15 chainerã®ãã¼ã¸ã§ã³åºå®ã«é¢ãã¦è¿½è¨
趣å³ã¯äººå·¥ç¥è½ã§ã
ãæ代ã¯äººå·¥ç¥è½ã ããï¼ã¨ãããã¨ã§ãæ°ããªè¶£å³ã¨ãã¦æ©æ¢°å¦ç¿ã®åéãå¦ç¿ãã¦ãã¾ãããã£ã±ãè±å½¢ã¯ãã£ã¼ãã©ã¼ãã³ã°ã§ããããä¸å¿å ¥éæ¸çãªä¸è¨ã®æ¬ãåèæ¸ã¨ãã¦èªãã§ããã®ã§ããã20ãã¼ã¸ç®ãããããåå¾®åæ¹ç¨å¼ãããããåºã¦ãã¦ãé ããããããªãããã«ãªã£ã¦ãã¾ãã
ã¤ã©ã¹ãã§å¦ã¶ ãã£ã¼ãã©ã¼ãã³ã° (KSæ å ±ç§å¦å°éæ¸)
- ä½è : å±±ä¸é義
- åºç社/ã¡ã¼ã«ã¼: è¬è«ç¤¾
- çºå£²æ¥: 2016/02/23
- ã¡ãã£ã¢: åè¡æ¬ï¼ã½ããã«ãã¼ï¼
- ãã®ååãå«ãããã° (5件) ãè¦ã
ãã¡ãã£ã¨æ°å¼ã追ãã®ãéçãæãå§ãã¦ããã®ã§ããçå±ããå®è·µæ´¾ï¼ãã¨ããããã«ããã¡ãªããããããã¤ã¤ãè²ã ãã£é£ã°ãã¦é¢ç½ãããªã¢ããªã±ã¼ã·ã§ã³ãã¨ãããã試ããªããç解ãæ·±ããä½æ¦ã«å¤æ´ãã¾ãããããã¦ãã£ã¼ãã©ã¼ãã³ã°ã¨ããã°ãã£ã±ãç»åèªèã ããã¨ãããã¨ã§ãä»åã¯ç»åèªèããã£ã¦ã¿ã¾ããã¡ãªã¿ã«ä¸è¨ã®åèæ¸ããææ¬ã«ãã£ãã®ã§ãããä¸ç´è åãã«è²ã 説æãå²æãã¦æ¸ããã¦ããã®ã¨ãæ¬ã®ããã°ã©ã ãå¾®å¦ã«çç¥ããã¦ãããã§ã¡ãã£ã¨ããå°çã§ããããããªããã§ãä»åã¯åèæ¸ã®è£è¶³ãå ¼ãã¦ãããå°ãå ¥éè åãã®ãã¥ã¼ããªã¢ã«ãæ¸ãã¦ã¿ã¾ãã
ããã®å¾ã¯ä¾ã«ãã£ã¦å®å®èªãç¶ãã®ã§èå³ããæ¹ã®ã¿ç¶ããã覧ãã ããã
Mac + Chainerã§ç»åèªè
ãã¾ãã¯Macã§ã®å®æ½æ¹æ³ã§ãã
ç°å¢
- Mac Book Pro
- OS X Yosemite 10.10.5
Chainerã¤ã³ã¹ãã¼ã«
ãããããªãã¨å§ã¾ãã¾ãããã以ä¸è¨äºã®Chainerã®ç®æãåèã«ã¤ã³ã¹ãã¼ã«ãã¦ãã ããã
ãpyenvã¨ãé¢åããããï¼ã¨ãã人ã¯ã¨ãããã以ä¸å®è¡ããã°ã¤ã³ã¹ãã¼ã«ã§ããããããã¾ããã
$ pip install chainer==1.8.1
ãchainerã®ãã¼ã¸ã§ã³ãåºå®ãã¦ããã®ã¯ãchainerã®ã¡ã¸ã£ã¼ãã¼ã¸ã§ã³ã¢ãã(v2.0)ã§å¾æ¹äºææ§ãç¡ããªã£ãããã§ãã
ãã¾ããç»åå¦çã®ã©ã¤ãã©ãªã§ããPILã使ãããã°ã©ã ãããã®ã§ã以ä¸ã³ãã³ãã§PILäºæã®pillowãã¤ã³ã¹ãã¼ã«ãã¦ããã¨ããã§ãã
$ pip install pillow
äºåæºå
ãHomebrewãã¤ã³ã¹ãã¼ã«ããã¦ããåæã§ããHomebrewã«é¢ãã¦ã¯ä»¥ä¸åç §ãã ããã
ãè²ã ãã¦ã³ãã¼ãããããã«ã以ä¸å®è¡ãã¦ãã¦ã³ãã¼ããã¼ã«ã®wgetãã¤ã³ã¹ãã¼ã«ã
$ brew install wget
ImgeNet2012ã®ç»åãã¡ã¤ã«åã»ã©ãã«ä¸è¦§ãã¦ã³ãã¼ã
ãImageNetã¨ãã大éã®ç»åãµã³ãã«ãç¨æããã¦ãããã¼ã¿ã»ããã®æ å ±ããã¦ã³ãã¼ãããããã以ä¸ã³ãã³ããå®è¡ãã¾ãã
$ cd $ git clone https://github.com/BVLC/caffe.git $ cd caffe/data/ilsvrc12 $ ./get_ilsvrc_aux.sh
ãæå¾ã¾ã§å®è¡ããã¨caffe/data/ilsvrc12
ä¸ã«è¤æ°ã®ãã¡ã¤ã«ããã¦ã³ãã¼ãããã¾ãããã®ä¸ã®ä¸ã¤ã®ãã¡ã¤ã«ã§ããsynset_words.txt
ã®ä¸èº«ãã¿ãã¨ã969è¡ç®ã«cupã¨æ¸ããã¦ãããã¨ããããã¾ããããã¯cupã969çªç®ã®ã¯ã©ã¹ã¨ããæå³ãããã§ããä»åã¯æç§æ¸ã«ç¿ã£ã¦ã«ãããèªèãããã¨æãã®ã§ããããè¦ãã¦ããã¾ãã
Caffeã®å¦ç¿æ¸ã¿ã¢ãã«ã®ã¤ã³ãã¼ã
ãChainerã¯Caffeã¨ããããã¾ãå¥ã®ãã£ã¼ãã©ã¼ãã³ã°ã®ãã¬ã¼ã ã¯ã¼ã¯ã®å¦ç¿ã¢ãã«ã使ç¨ã§ããã®ãç¹å¾´ãããã§ãã以ä¸ã§ãã¦ã³ãã¼ãã§ãã¾ãã
$ cd $ git clone https://github.com/pfnet/chainer.git $ cd chainer/examples/modelzoo $ python download_model.py caffenet $ python download_mean_file.py
python download_model.py
ã§å¦ç¿æ¸ã¿ã¢ãã«ããã¦ã³ãã¼ããã¦ãã¾ããå¾ãã®caffenet
ã¯ã¢ãã«åã表ãã¦ãã¾ããé¸æã§ããã¢ãã«åã¯alexnet
, caffenet
, googlenet
, resnet
ã®4種é¡ããã¾ãã200MB以ä¸ããã®ã§ããã¦ã³ãã¼ãã¯ããªãæéããããã¾ããæ°é·ã«å¾
ã¡ã¾ããä¸è¨ã®ã³ãã³ãæã¡çµããã¨åãã£ã¬ã¯ããªbvlc_reference_caffenet.caffemodel
㨠ilsvrc_2012_mean.npy
ã®2ã¤ã®ãã¡ã¤ã«ãçæããã¾ãã
ãä»åã¯ã«ãããèªèãããã®ã§ãã«ããã®ç»åãã¡ã¤ã«ãç¨æãã¾ãã家ã«ããé©å½ãªã«ããã®åçãiPhoneã§æ®å½±ãã¦ãåããã£ã¬ã¯ããªï¼~/chainer/examples/modelzoo
)ã«cup.jpg
ãä¿åãã¾ãã
ããããªãã¤ãã
ãç¶ãã¦ãä»åã®ãã¹ãç¨ã®ãã¡ã¤ã«test.txt
ãä½æãã¾ãã
$ vim test.txt
ãä¸èº«ã¯ä»¥ä¸ã¨ãã¾ãã
cup.jpg 969
ãcup.jpg
ã¯ãã¡ãããå
ã»ã©ä¿åããã«ããã®åçã®ãã¡ã¤ã«åã§ãã969ã¯cupã®ã¯ã©ã¹çªå·ã§ãã以ä¸ã®ã³ãã³ããå®è¡ããã¨ãcup.jpg
ã969çªç®ã®ã¯ã©ã¹ãã¤ã¾ãcupã¨ã©ãã ãä¸è´ãã¦ããããè©ä¾¡ãããã¨ãã§ãã¾ãã
$ python evaluate_caffe_net.py test.txt caffenet bvlc_reference_caffenet.caffemodel -b ./ -B 1
ãçµæã¯ä»¥ä¸ãã¡ãªã¿ã«Loading Caffe model fileã®å¾ãLoadedã表示ãããã¾ã§2,3åãããã¾ããããããªã«æéããããã®ãªã®ï¼ï¼
Loading Caffe model file bvlc_reference_caffenet.caffemodel... Loaded mean loss: 8.06329917908 mean accuracy: 0.0
ãçµæã¯â¦ããããããããã¾ãããã
ããã°ã©ã ã®æ¹è¯
ã詳細ãªçµæã表示ãããããã«ãããã°ã©ã ãåèæ¸ã®éãæ¹é ãã¦ã¿ããã¨æã£ãã®ã§ããããã¼ã¸ã§ã³ã®éããªã®ãæ¬ã®èª¤è¨ãªã®ããä½ç®æãèªåã§èãã¦ä¿®æ£ããªãã¨ããã¾ããã§ããï¼è¾ãï¼ããã¨ãå ã®ããã°ã©ã ãã使ããããããããã«ãã³ãã³ãã®å¼æ°ã«ç»åã®ãã¡ã¤ã«åãå ¥åããã¨èªèããããã«ãã¾ãããããã°ã©ã ã¯GitHubã«ããã¾ããã
ãREADMEã«è¨è¼ãã¦ããã¾ããã使ãæ¹ã¯ä»¥ä¸ã§ããã¡ãªã¿ã«ãImgeNet2012ã®ç»åãã¡ã¤ã«åã»ã©ãã«ä¸è¦§ãã¦ã³ãã¼ããã¨ãCaffeã®å¦ç¿æ¸ã¿ã¢ãã«ã®ã¤ã³ãã¼ããã¯å®äºãã¦ããåæã§ãã®ã§ã¾ã ã®äººã¯ãã®è¨äºãæåããèªãã§ãã£ã¦ããã¦ãã ããã
ãã¾ãããªãã¸ããªãã¯ãã¼ã³
$ git clone https://github.com/karaage0703/deeplearning-learning
$ cd deeplearning-learning
ãå¿ è¦ãªãã¡ã¤ã«ãã³ãã¼
$ cp ~/chainer/examples/modelzoo/ilsvrc_2012_mean.npy ./ $ cp ~/chainer/examples/modelzoo/bvlc_reference_caffenet.caffemodel ./ $ cp ~/caffe/data/ilsvrc12/synset_words.txt ./
ãã«ããã®èªèå®è¡
$ python evaluate_caffe_net_ranking.py cup.jpg caffenet bvlc_reference_caffenet.caffemodel -b ./
1 | n07930864 cup | 46.7% 2 | n03063599 coffee mug | 46.3% 3 | n03775546 mixing bowl | 2.4% 4 | n07920052 espresso | 2.4% 5 | n04263257 soup bowl | 1.6%
ããµãããããã«ã«ããã£ã½ããã®ã¨ãã¦èªèããã¦ããããã§ããã¤ãã§ã«æå ã«ãã£ããããã®åçã§ã試ãã¦ã¿ããã¨æãã¾ãã
ããããªã®ã
ãä¸è¨ã³ãã³ãå®è¡ãå¼æ°ã®cup.jpg
ãbanana.jpg
ã«å¤æ´ã¦ãã¾ãã
$ python evaluate_caffe_net_ranking.py banana.jpg caffenet bvlc_reference_caffenet.caffemodel -b ./
1 | n07753592 banana | 78.8% 2 | n07716358 zucchini, courgette | 8.9% 3 | n03476684 hair slide | 1.4% 4 | n07718472 cucumber, cuke | 1.2% 5 | n01694178 African chameleon, Chamaeleo chamaeleon | 1.1%
ãããã78%ï¼åãï¼
ãã§ã¯ãæå¾ã«æä¾ã®ããªã¼ç´ æï¼ãããã (id:lonestartx) ãã
ããã¯ããªãã¡ã¬ã³ã¹ï¼ãã¤ããããã¨ããããã¾ãã
1 | n04201297 shoji | 63.8% 2 | n04005630 prison, prison house | 29.1% 3 | n04239074 sliding door | 3.1% 4 | n04589890 window screen | 0.8% 5 | n03617480 kimono | 0.3%
ã以åãRaspberry Pi + DeepBeliefSDKãã§å®æ½ããã¨ãã¯50%éå(shoji)ã§ããããä»åã¯ãªãã¨60%以ä¸éåï¼ãã¯ãããããããã¯éåã§ããã
ã¢ãã«ãå¤ãã¦ãã£ã¬ã³ã¸
ããã£ãããªã®ã§googlenet
ã®ã¢ãã«ã§ã試ãã¦ã¿ã¾ãããã¢ãã«ã®ãã¦ã³ãã¼ãã¨ã³ãã¼ã¯ä»¥ä¸ã
$ cd ~/chainer/examples/modelzoo
$ python download_model.py googlenet
$ cp ~/chainer/examples/modelzoo/bvlc_googlenet.caffemodel ./
ããã¨ã¯ã以ä¸ã§å®è¡ã§ãã¾ãã
$ cd ~/deeplearning-learning $ python evaluate_caffe_net_ranking.py cup.jpg googlenet bvlc_googlenet.caffemodel -b ./
ãã«ããããããããã³ã¹ã¿ããã®å®è¡çµæã¯ä»¥ä¸ã®ãããªæãã
1 | n07930864 cup | 70.8% 2 | n03063599 coffee mug | 8.6% 3 | n04263257 soup bowl | 7.9% 4 | n03775546 mixing bowl | 7.3% 5 | n03733805 measuring cup | 2.6%
1 | n07753592 banana | 100.0% 2 | n07716358 zucchini, courgette | 0.0% 3 | n01945685 slug | 0.0% 4 | n13054560 bolete | 0.0% 5 | n04332243 strainer | 0.0%
1 | n04201297 shoji | 99.5% 2 | n04239074 sliding door | 0.2% 3 | n04589890 window screen | 0.1% 4 | n04005630 prison, prison house | 0.1% 5 | n04590129 window shade | 0.0%
ãããã100%ï¼ éå 99.5%ï¼ googlenet
ã®æ¹ããã¡ã¤ã«ãµã¤ãºãå°ããããæ§è½ãè¯ããããæµç³googleå
çï¼ï¼
ãªã¢ã«ã¿ã¤ã ã®èªè
ãid:shi3z ãããä¸è¨è¨äºã§è§£èª¬ãã¦ãããããªãã«ã¡ã©ã§ãªã¢ã«ã¿ã¤ã ã«èªèãããããªãã¢ãé常ã«é¢ç½ãã§ãã
ãMITã©ã¤ã»ã³ã¹ã§å ¬éããã¦ããã®ã§ãç§ã®ãªãã¸ããªã«ãç§ã®ç°å¢ã«åããã¦å°ãã ãä¿®æ£ãããã®ãåãè¾¼ã¾ããã¦ããã ãã¾ãããä»ã¾ã§ã®ã»ããã¢ãããå®äºãã¦ãããã以ä¸ã®ã³ãã³ãå®è¡ããã ãã§ãã¢ãèµ·åããã¯ãã§ããã«ã¡ã©ã®ç»åãç¬æã«èªèãã¦ããæ§ã¯ããªã楽ããã§ãã
$ python inspect_camera.py caffenet bvlc_reference_caffenet.caffemodel
Raspberry Pi 3 + Chainerã§ç»åèªè
ãRaspberry Pi 3ã«ãChainerãã¤ã³ã¹ãã¼ã«ãã¦è©¦ãã¦ã¿ã¾ããã
ãRaspberry Pi 3èªä½ã®åºæ¬çãªã»ããã¢ããã¯ä»¥ä¸åç §ä¸ããã
ãRaspberry Piã¸ã®Chainerã®ã¤ã³ã¹ãã¼ã«ã¯ä»¥ä¸ã³ãã³ãå®è¡ä¸ããã
$ sudo apt-get update $ sudo apt-get install python-pip python-dev $ sudo pip install cython $ sudo apt-get install libhdf5-dev $ sudo pip install chainer==1.8.1
ããã¨ã®è¦é ã¯Macã¨åãã§ããã¾ãã¯caffenet
ã§è©¦ãã¦ã¿ãã®ã§ããã以ä¸ã®éãã¢ãã«ããã¼ãã§ããã«è½ã¡ã¦ãã¾ãã¾ããããã¯ãRaspberry Piã«ã¯è·ãéããããâ¦
Load file=cup.jpg Loading Caffe model file bvlc_reference_caffenet.caffemodel... å¼·å¶çµäº
ãããããããã次ã¯googlenet
ã§è©¦ãã¦ã¿ãã¨â¦
Load file=cup.jpg Loading Caffe model file bvlc_googlenet.caffemodel... Loaded 1 | n07930864 cup | 70.5% 2 | n03063599 coffee mug | 8.4% 3 | n04263257 soup bowl | 8.0% 4 | n03775546 mixing bowl | 7.6% 5 | n03733805 measuring cup | 2.7%
ãã§ããï¼ã¢ãã«ã®ãã¼ãã¨èªèãMacã¨æ¯ã¹ã¦ããªãæéããã£ããã©ã§ãããï¼
ãããããããæãã¨ãRaspberry Pi 2ã§ãå®æéã§ä½¿ãããDeepBeliefSDKãã¯åããªã¨æ¹ãã¦æãã¾ããã
ã¾ã¨ã
ãã¨ããããå®è·µããå ¥ã£ã¦ç»åèªèããã¨ããã¾ã§ã¯ã§ãã¾ãããåèæ¸ã®æ¹ãé å¼µã£ã¦èªã¿é²ãã¦çå±ã®æ¹ããã£ããã¢ããããããã¨ããã§ããä»åã¯ãå¦ç¿ãã¼ã¿ã¯å®å ¨ã«ãããã®ã使ã£ãã®ã§ã次ã¯å¦ç¿ãããã£ã¦ã¿ããã¨ããã§ãã以ä¸ãµã¤ããèªåã«ãã§ããããªã¬ãã«ã§å¦ç¿ã®ä»æ¹ãåãããããæ¸ããã¦ãã¦ããããã§ããï¼æ£ç¢ºã«ã¯æèªãã ã¨ãã¯è¯ãããããªãã£ããã©ãããããå°ãç解ã§ããããã«ãªã£ãï¼ã
ããã ã家ã®Macã ã¨ã©ãã ãå¦ç¿ã«æéãããã®ã ãããâ¦AWSãµã¼ãã¨ã使ããªãã¨ãã¡ããªã
- åºç社/ã¡ã¼ã«ã¼: TechShare
- ã¡ãã£ã¢: ã¨ã¬ã¯ãããã¯ã¹
- ãã®ååãå«ãããã° (4件) ãè¦ã
2016/08/04追è¨ï¼ ãCaffeã¢ãã«ã®èªã¿è¾¼ã¿ãé ãã£ãã®ã§ãçéã«ãã¾ãããã¨ãã£ã¦ãRaspberry Piã ã¨ããã§ãèªèã«30ç§ããã£ã¦ãã¾ãã¾ããâ¦
åèãªã³ã¯
ChainerのNINで自分の画像セットを深層学習させて認識させる - shi3zの長文日記
CUDAなしMacで、Chainer使ってCaffeモデルをインポートして画像認識させてみる - shi3zの長文日記
【ディープラーニング】10時間でChainerの基本を身につける - あれもPython,これもPython
リバストのブログ Deep Learningの開発環境(Caffeの動作確認)
é¢é£è¨äº
ãRaspberry Piã¨TensorFlowã®çµã¿åããã§ãã£ã¼ãã©ã¼ãã³ã°ããã¦ã¿ã¾ãããTensorFlow使ãããå ´åã¯åèã«ãã¦ã¿ã¦ä¸ãã