5
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

TensorFlow on Raspberry Pi3

Last updated at Posted at 2017-09-10

参考資料

RaspberyPi用のtensorlow。要RasPi3
https://github.com/samjabrahams/tensorflow-on-raspberry-pi

KaresとOpenJtalkを使うやりかた
http://qiita.com/PonDad/items/9fbdf4d694f825dd1b6e

Tensorflowをビルドしてカメラ画像の認識
http://qiita.com/kei_bility/items/1832ad495c0a88bde9c3

試してみる

  • Raspbian Jessi 2017-04
  • RaspberryPi3
  • Python3
  • Webインターフェース

19:00- 環境を最新に


sudo apt-get update; sudo apt-get upgrade

19:10- 関連のインストール


sudo apt-get install python3-pip python3-dev
sudo apt-get install git
sudo apt-get install vim apache2

Keras 使う場合

19:15- 必要なpythonのライブラリ


sudo apt-get install python3-scipy python3-h5py libyaml-dev

19:30- KerasとかTensorFlowとか


 sudo pip3 install keras
 wget https://github.com/samjabrahams/tensorflow-on-raspberry-pi/releases/download/v1.1.0/tensorflow-1.1.0-cp34-cp34m-linux_armv7l.whl

20:10- pipの操作


sudo pip3 install tensorflow-1.1.0-cp34-cp34m-linux_armv7l.whl

mockはアンインストールしてインストールし直す

sudo pip3 uninstall mock
Cannot uninstall requirement mock, not installed
Storing debug log for failure in /root/.pip/pip.log

 sudo pip3 install mock

学習モデルをつくる

ダウンロード


git clone https://github.com/fchollet/deep-learning-models



$ cd deep-learning-models
[deep-learning-models/raspberrypi 20:22:03] $ ls
LICENSE    audio_conv_utils.py  inception_v3.py       resnet50.py  vgg19.py
README.md  imagenet_utils.py    music_tagger_crnn.py  vgg16.py     xception.py

象の写真をダウンロード


[deep-learning-models/raspberrypi 20:22:18] $ wget https://qiita-image-store.s3.amazonaws.com/0/47128/27d61878-4275-1ef4-c580-28df98e8bd91.jpeg
--2017-06-03 20:22:43--  https://qiita-image-store.s3.amazonaws.com/0/47128/27d61878-4275-1ef4-c580-28df98e8bd91.jpeg
qiita-image-store.s3.amazonaws.com (qiita-image-store.s3.amazonaws.com) をDNSに問いあわせています... 52.219.68.45
qiita-image-store.s3.amazonaws.com (qiita-image-store.s3.amazonaws.com)|52.219.68.45|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 3226734 (3.1M) [image/jpeg]
`27d61878-4275-1ef4-c580-28df98e8bd91.jpeg' に保存中

27d61878-4275-1ef4- 100%[=====================>]   3.08M  1.07MB/s 時間 2.9s

2017-06-03 20:22:46 (1.07 MB/s) - `27d61878-4275-1ef4-c580-28df98e8bd91.jpeg' へ保存完了 [3226734/3226734]

[deep-learning-models/raspberrypi 20:22:46] $ ls
27d61878-4275-1ef4-c580-28df98e8bd91.jpeg  imagenet_utils.py     vgg16.py
LICENSE                                    inception_v3.py       vgg19.py
README.md                                  music_tagger_crnn.py  xception.py
audio_conv_utils.py                        resnet50.py
[deep-learning-models/raspberrypi 20:22:50] $ mv 27d61878-4275-1ef4-c580-28df98e8bd91.jpeg elephant.jpg
[deep-learning-models/raspberrypi 20:22:58] $ ls
LICENSE              elephant.jpg       music_tagger_crnn.py  vgg19.py
README.md            imagenet_utils.py  resnet50.py           xception.py
audio_conv_utils.py  inception_v3.py    vgg16.py

実行してみる

象の写真を読ましています



[deep-learning-models/raspberrypi 20:23:16] $ python3 inception_v3.py
Using TensorFlow backend.
Downloading data from https://github.com/fchollet/deep-learning-models/releases/download/v0.5/inception_v3_weights_tf_dim_ordering_tf_kernels.h5
Downloading data from https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json
Predicted: [[('n01871265', 'tusker', 0.63436967), ('n02504458', 'African_elephant', 0.2854473), ('n02504013', 'Indian_elephant', 0.033294968), ('n03000134', 'chainlink_fence', 0.00040027319), ('n03980874', 'poncho', 0.0002730588)]]
[deep-learning-models/raspberrypi 20:27:44] $


うまくいきました


[deep-learning-models/raspberrypi 21:08:48] $ ls
LICENSE              elephant.jpg       music_tagger_crnn.py  vgg19.py
README.md            imagenet_utils.py  resnet50.py           xception.py
audio_conv_utils.py  inception_v3.py    vgg16.py

別の写真も試してみる


[deep-learning-models/raspberrypi 21:15:27] $ wget https://upload.wikimedia.org/wikipedia/commons/thumb/9/98/Elephas_maximus_%28Bandipur%29.jpg/1024px-Elephas_maximus_%28Bandipur%29.jpg
--2017-06-03 21:15:59--  https://upload.wikimedia.org/wikipedia/commons/thumb/9/98/Elephas_maximus_%28Bandipur%29.jpg/1024px-Elephas_maximus_%28Bandipur%29.jpg
upload.wikimedia.org (upload.wikimedia.org) をDNSに問いあわせています... 198.35.26.112, 2620:0:863:ed1a::2:b
upload.wikimedia.org (upload.wikimedia.org)|198.35.26.112|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 269462 (263K) [image/jpeg]
`1024px-Elephas_maximus_(Bandipur).jpg' に保存中

1024px-Elephas_maxi 100%[=====================>] 263.15K   283KB/s 時間 0.9s

2017-06-03 21:16:01 (283 KB/s) - `1024px-Elephas_maximus_(Bandipur).jpg' へ保存完了 [269462/269462]

[deep-learning-models/raspberrypi 21:16:01] $ mv 1024px-Elephas_maximus_\(Bandipur\).jpg elephant2.jpg
[deep-learning-models/raspberrypi 21:16:08] $ cp elephant2.jpg elephant.jpg     [deep-learning-models/raspberrypi 21:16:18] $ python3 inception_v3.py           Using TensorFlow backend.
Predicted: [[('n01871265', 'tusker', 0.862279), ('n02504458', 'African_elephant', 0.08213596), ('n02504013', 'Indian_elephant', 0.018105704), ('n03075370', 'combination_lock', 0.00025089187), ('n03874599', 'padlock', 0.00019190098)]]
[deep-learning-models/raspberrypi 21:19:22] $ python3 inception_v3.py
Using TensorFlow backend.
Predicted: [[('n01871265', 'tusker', 0.862279), ('n02504458', 'African_elephant', 0.08213596), ('n02504013', 'Indian_elephant', 0.018105704), ('n03075370', 'combination_lock', 0.00025089187), ('n03874599', 'padlock', 0.00019190098)]]

手を加えてみる

学習済みモデルはどこにあるのかな


[deep-learning-models/raspberrypi 21:22:51] $  find . -name imagenet_class_index.json
[deep-learning-models/raspberrypi 21:23:12] $ find . -name *.h5
[deep-learning-models/raspberrypi 21:23:30] $ ls
LICENSE              elephant1.jpg      music_tagger_crnn.py  xception.py
README.md            elephant2.jpg      resnet50.py
audio_conv_utils.py  imagenet_utils.py  vgg16.py
elephant.jpg         inception_v3.py    vgg19.py
[deep-learning-models/raspberrypi 21:23:34] $ du --max-depth=1 -h
592K    ./.git
4.3M    .
[deep-learning-models/raspberrypi 21:23:47] $ ls -alh
合計 3.7M
drwxr-xr-x 3 pi pi 4.0K  6月  3 21:16 .
drwxr-xr-x 5 pi pi 4.0K  6月  3 20:23 ..
drwxr-xr-x 8 pi pi 4.0K  6月  3 20:21 .git
-rw-r--r-- 1 pi pi 1.1K  6月  3 20:21 LICENSE
-rw-r--r-- 1 pi pi 3.7K  6月  3 20:21 README.md
-rw-r--r-- 1 pi pi 2.8K  6月  3 20:21 audio_conv_utils.py
-rw-r--r-- 1 pi pi 264K  6月  3 21:16 elephant.jpg
-rw-r--r-- 1 pi pi 3.1M  1月  2 01:06 elephant1.jpg
-rw-r--r-- 1 pi pi 264K 10月 30  2013 elephant2.jpg
-rw-r--r-- 1 pi pi 1.6K  6月  3 20:21 imagenet_utils.py
-rw-r--r-- 1 pi pi  15K  6月  3 20:21 inception_v3.py
-rw-r--r-- 1 pi pi 5.8K  6月  3 20:21 music_tagger_crnn.py
-rw-r--r-- 1 pi pi  12K  6月  3 20:21 resnet50.py
-rw-r--r-- 1 pi pi 8.6K  6月  3 20:21 vgg16.py
-rw-r--r-- 1 pi pi 8.8K  6月  3 20:21 vgg19.py
-rw-r--r-- 1 pi pi  12K  6月  3 20:21 xception.py
[deep-learning-models/raspberrypi 21:23:59] $ cd ..
[~/raspberrypi 21:24:08] $ pwd
/home/pi
[~/raspberrypi 21:24:10] $ du --max-depth=1 -h
92M     ./.keras
4.3M    ./deep-learning-models
281M    ./tensorflow-on-raspberry-pi
432M    .
[~/raspberrypi 21:24:14] $ ls
deep-learning-models
tensorflow-1.1.0-cp27-none-linux_armv7l.whl
tensorflow-1.1.0-cp34-cp34m-linux_armv7l.whl
tensorflow-on-raspberry-pi
[~/raspberrypi 21:24:21] $ cd .keras
[.keras/raspberrypi 21:24:28] $ ls
keras.json  models
[.keras/raspberrypi 21:24:29] $ find . -name *.h5
./models/inception_v3_weights_tf_dim_ordering_tf_kernels.h5
[.keras/raspberrypi 21:24:38] $ ls models
imagenet_class_index.json  inception_v3_weights_tf_dim_ordering_tf_kernels.h5
[.keras/raspberrypi 21:25:09] $ ls -alh models
合計 92M
drwxr-xr-x 2 pi pi 4.0K  6月  3 20:27 .
drwxr-xr-x 3 pi pi 4.0K  6月  3 20:25 ..
-rw-r--r-- 1 pi pi  35K  6月  3 20:27 imagenet_class_index.json
-rw-r--r-- 1 pi pi  92M  6月  3 20:26 inception_v3_weights_tf_dim_ordering_tf_kernels.h5

これか。
さて、元のディレクトリに戻って書き換えてみる


[deep-learning-models/raspberrypi 21:26:18] $ cp inception_v3.py inception_v3_p.py

あれこれ手を加えて

[deep-learning-models/raspberrypi 22:34:23] $ python3 inception_v3_p.py
2017-06-03 22:34:46.486806 python module importing..
Using TensorFlow backend.
2017-06-03 22:35:01.378615  model making...
>> https://upload.wikimedia.org/wikipedia/commons/f/f9/Zoorashia_elephant.jpg
d: 2017-06-03 22:37:10.923091
Predicted: [[('n02504013', 'Indian_elephant', 0.88748741), ('n02504458', 'African_elephant', 0.013440695), ('n01871265', 'tusker', 0.009208966), ('n02398521', 'hippopotamus', 0.0010945746), ('n02134084', 'ice_bear', 0.00081141439)]]
>> https://upload.wikimedia.org/wikipedia/commons/thumb/9/9e/Blue_tang_surgeonfish.jpg/1280px-Blue_tang_surgeonfish.jpg
d: 2017-06-03 22:38:18.114109
Predicted: [[('n09256479', 'coral_reef', 0.90472144), ('n10565667', 'scuba_diver', 0.013638749), ('n04296562', 'stage', 0.0080893962), ('n02488291', 'langur', 0.0036474653), ('n04251144', 'snorkel', 0.0025966684)]]
>> ^CTraceback (most recent call last):
  File "inception_v3_p.py", line 410, in <module>
    url_path = input('>> ')
KeyboardInterrupt
^C
[deep-learning-models/raspberrypi 22:39:12] $ ^C
[deep-learning-models/raspberrypi 22:39:12] $ vim inception_v3_p.py

喋らせる


[deep-learning-models/raspberrypi 22:45:06] $ sudo apt-get install espeak
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
  espeak-data libasyncns0 libespeak1 libflac8 libice6 libjack-jackd2-0 libogg0
  libopus0 libportaudio2 libpulse0 libsm6 libsndfile1 libsonic0 libvorbis0a
  libvorbisenc2 libx11-xcb1 libxi6 libxtst6 x11-common
提案パッケージ:
  jackd2 opus-tools pulseaudio
以下のパッケージが新たにインストールされます:
  espeak espeak-data libasyncns0 libespeak1 libflac8 libice6 libjack-jackd2-0
  libogg0 libopus0 libportaudio2 libpulse0 libsm6 libsndfile1 libsonic0
  libvorbis0a libvorbisenc2 libx11-xcb1 libxi6 libxtst6 x11-common
アップグレード: 0 個、新規インストール: 20 個、削除: 0 個、保留: 0 個。
2,783 kB のアーカイブを取得する必要があります。
この操作後に追加で 6,382 kB のディスク容量が消費されます。
続行しますか? [Y/n] y
取得:1 http://archive.raspberrypi.org/debian/ jessie/main x11-common all 1:7.7+16 [251 kB]
取得:2 http://mirrordirector.raspbian.org/raspbian/ jessie/main libasyncns0 armhf 0.8-5 [11.4 kB]

...

espeak (1.48.04+dfsg-1) を設定しています ...
libc-bin (2.19-18+deb8u9) のトリガを処理しています ...
systemd (215-17+deb8u7) のトリガを処理しています ...


[deep-learning-models/raspberrypi 22:45:57] $ espeak test
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started

喋らない


[deep-learning-models/raspberrypi 22:46:02] $ amixer
Simple mixer control 'PCM',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback -10239 - 400
  Mono: Playback -2000 [77%] [-20.00dB] [on]
[deep-learning-models/raspberrypi 22:46:16] $ amixer cset numid=3 1
numid=3,iface=MIXER,name='PCM Playback Route'
  ; type=INTEGER,access=rw------,values=1,min=0,max=2,step=0
  : values=1

[deep-learning-models/raspberrypi 22:47:21] $ espeak test
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started

聞こえない


[deep-learning-models/raspberrypi 22:47:27] $ alsamixer

ボリューム100%にして


[deep-learning-models/raspberrypi 22:47:39] $ espeak test
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
[deep-learning-models/raspberrypi 22:47:42] $ espeak test
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started

聞こえた

連動させる


[deep-learning-models/raspberrypi 22:54:49] $ vim inception_v3_p.py
[deep-learning-models/raspberrypi 22:55:30] $ python3 inception_v3_p.py
2017-06-03 22:55:33.585649 python module importing..
Using TensorFlow backend.
2017-06-03 22:55:48.815163  model making...
>> https://upload.wikimedia.org/wikipedia/commons/thumb/3/38/Le_carrelet_sur_ponton_%C3%A0_la_Pointe_du_Chay_Nord_%281%29.JPG/800px-Le_carrelet_sur_ponton_%C3%A0_la_Pointe_du_Chay_Nord_%281%29.JPG
d: 2017-06-03 22:58:07.282015
This is  drilling_platform
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
>> 

結果、作ったもの。


# diff inception_v3.py inception_v3_p.py 
17a18,24
> import datetime
> import urllib.request
> import subprocess
> 
> d = datetime.datetime.today()
> print(d,'python module importing..')
> 
398a406,407
>     d = datetime.datetime.today()
>     print(d,' model making...')
401,409c410,423
<     img_path = 'elephant.jpg'
<     img = image.load_img(img_path, target_size=(299, 299))
<     x = image.img_to_array(img)
<     x = np.expand_dims(x, axis=0)
< 
<     x = preprocess_input(x)
< 
<     preds = model.predict(x)
<     print('Predicted:', decode_predictions(preds))
---
>     while 1:
>       url_path = input('>> ')
>       urllib.request.urlretrieve(url_path, 'check.jpg')
>       img_path = ('check.jpg')
> 
>       img = image.load_img(img_path, target_size=(299, 299))
>       x = image.img_to_array(img)
>       x = np.expand_dims(x, axis=0)
>       x = preprocess_input(x)
>       preds = model.predict(x)
>       recognize = decode_predictions(preds)
>       identification = recognize[0][0][1]
>       print('This is ', identification)
>       subprocess.check_output(["espeak","-k5","-s150",identification])

主な変更点

  • 準備処理の時間をわかりやすくするために、時刻表示をつけている
  • 準備が終わると入力待ちになり、URLを入力するとダウンロードして処理する
  • 最有力候補のみ表示するように変更
  • 最有力候補を音声出力
  • 1回処理しても終わらず次の入力を待つ
5
8
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
5
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?