画像認識 続き

orangeの画像を拾ってきて認識できるかやってみた。

f:id:tatsuzou-hasegawa:20170521163747j:plain

画像の名前はelephant.jpgに変える。

 

f:id:tatsuzou-hasegawa:20170521163905p:plain

下から8行目にorangeと返してきました。

何故かエラーも吐くのですが、まあいいか。

このままでは不十分なので変更が必須ですが、今日のところはこの辺で。

raspberry Pi3で画像認識 できたぞー

2017/5/20

前回はメモリが足らないと言っている感じなので、ubuntuスワップを増やすようにした。
で、1GBをスワップに当ててから再度やってみる


$ python3 inception_v3.py
Using TensorFlow backend.
Traceback (most recent call last):
File "inception_v3.py", line 403, in <module>
img = image.load_img(img_path, target_size=(299, 299))
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/preprocessing/image.py", line 318, in load_img
raise ImportError('Could not import PIL.Image. '
ImportError: Could not import PIL.Image. The use of `array_to_img` requires PIL.
Exception ignored in: <bound method Session.__del__ of <tensorflow.python.client.session.Session object at 0x6e057b30>>
Traceback (most recent call last):
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 587, in __del__
AttributeError: 'NoneType' object has no attribute 'TF_NewStatus'

うーん、また違うエラー・・・
PILがないときたのでinstall

現在ではpilよりpillowを入れている人が多いみたいなのでまずはこっちを入れてみる


$ pip3 install pillow
Collecting pillow
Downloading Pillow-4.1.1.tar.gz (11.3MB)
100% |████████████████████████████████| 11.3MB 23kB/s
Collecting olefile (from pillow)
Downloading olefile-0.44.zip (74kB)
100% |████████████████████████████████| 81kB 1.8MB/s
Building wheels for collected packages: pillow, olefile
Running setup.py bdist_wheel for pillow ... done
Stored in directory: /home/hase/.cache/pip/wheels/81/db/ec/08c4136b89406550fd25de7eaa617024c8762c58f6aceb339c
Running setup.py bdist_wheel for olefile ... done
Stored in directory: /home/hase/.cache/pip/wheels/20/58/49/cc7bd00345397059149a10b0259ef38b867935ea2ecff99a9b
Successfully built pillow olefile
Installing collected packages: olefile, pillow
Successfully installed olefile-0.44 pillow-4.1.1

とりあえずいれてみたので、またやってみる

hase@hase-desktop:~/Documents/deep-learning-models-master$ python3 inception_v3.py
Using TensorFlow backend.
Traceback (most recent call last):
File "inception_v3.py", line 403, in <module>
img = image.load_img(img_path, target_size=(299, 299))
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/preprocessing/image.py", line 320, in load_img
img = pil_image.open(path)
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/PIL/Image.py", line 2410, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'elephant.jpg'
hase@hase-desktop:~/Documents/deep-learning-models-master$

・・・/PIL/Image.pyがないので写真も見つからないはずだ。
どうしようと思ったが、調べてみるとPILはすでに入っている。
ということは、単にファイルが見つからないだけか?

ということで、elephant.jpgをそこら中に入れてみたところ、
inception_v3.pyと同じディレクトリで良いことがわかった。


で、試した結果が次のログ。
象の写真をやってみた。

hase@hase-desktop:~/Documents/deep-learning-models-master$ python3 inception_v3.py
Using TensorFlow backend.
Label: tusker
hase@hase-desktop:~/Documents/deep-learning-models-master$

きばのある動物、と回答。
まあ、そのとおりなんですが。
elephant.jpgという名前でりんごの写真を入れてみた。


hase@hase-desktop:~/Documents/deep-learning-models-master$ python3 inception_v3.py
Using TensorFlow backend.
Label: Granny_Smith
hase@hase-desktop:~/Documents/deep-learning-models-master$

Granny_Smith りんごの種類ですね。ある意味正解。

 

先人に感謝・・・(^人^)

 

2週間かかりましたができました(平日は全然やっていませんが)

 

keras 再install -> 結局pythonから再install 

kerasがうまく動作していないようで、悪戦苦闘しましたが、結局直せず再installすることにしました。python3.4ではなく、3.5を入れてしまったためkerasでエラーを吐くという罠に落ちました。

その悪戦苦闘ぶりを下記に記します。

また最後にはエラーで止まるという不幸っぷりです。

2017/5/20と記載されたところからが最新となります。

この2週間の残念なlogです。

 

 

https://github.com/samjabrahams/tensorflow-on-raspberry-pi/

ここのサイトに従ってinstallしたが、pip install からできなくなっていた。
このプラットフォームではできないとエラーを返される。

他のサイトにはMATEでもinstallしたとかいてあるので、できないことはないはず。
DEEPAGEというサイト(Tensorflowのインストール方法のページ)に従うことにしてやってみる。
環境変数とかの設定をやらないといけないらしい。
https://deepage.net/tensorflow/2017/01/17/how-to-install-tensorflow.html

$ sudo apt-get update
$ sudo apt-get install -y git build-essential libssl-dev language-pack-id
$ export LC_ALL=C
$ sudo dpkg-reconfigure locales

このlocaleでは設定がわからなかったのでALLを選択してしまった。。。
installに時間がかかる・・・

あれ、ここに書いてあった・・・
https://github.com/samjabrahams/tensorflow-on-raspberry-pi

Vice-versa for trying to install the Python 3 wheel. If you get the error "tensorflow-1.1.0-cp34-cp34m-any.whl is not a supported wheel on this platform.", try this command:

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

なにやら環境変数が重要っぽいので設定するDEEPAGEのHPから転載
export LC_ALL=C

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
exec $SHELL

今となっては必要かどうかわからないけど、やってから下のことをやったので、とりあず記載。

 


これでもだめなので、pythonのversion3.4.1を入れる。
$ pyenv install 3.4.1
30分位かかった

$ pyenv -V
3.5.1
このままではだめなので、入れ替える
$ pyenv global 3.4.1
$ pyenv -V
3.4.1

sudo pip3 install tensorflow-1.1.0-cp34-cp34m-linux_armv7l.whl
とやるとまたエラーが出る。どうもディレクトリの使用権利がないっぽい。
SUDOでなぜだめなのかわからないが、とりあえずSUDOを外す。

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

なんか通った・・・・成功しました。
Installing /home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/protobuf-3.3.0-py3.4-nspkg.pth
Successfully installed tensorflow numpy six protobuf wheel werkzeug
Cleaning up...

 

 

kerasのinstallで時間がかかりしかも見当たらないとでるのでkerasの再install

今度はtensorflowが見当たらないというのでまたinstallの必要?かと思ったのですが
anacondaがだめだとかいてあったので、install
http://stackoverflow.com/questions/39371772/how-to-install-anaconda-on-raspberry-pi-3-model-b


sudoと一般時の立ち上がりpythonのversionが違う。
なぜかを調べるには
env | grep PATH
sudo env | grep PATH
を実行すると、

hase@hase-desktop:/$ env |grep PATH
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
DEFAULTS_PATH=/usr/share/gconf/mate.default.path
PATH=/usr/local/pyenv/shims:/usr/local/pyenv/bin:/usr/local/pyenv/shims:/usr/local/pyenv/bin:/home/hase/.pyenv/shims:/home/hase/miniconda3/bin:/home/hase/.pyenv/shims:/home/hase/.pyenv/bin:/home/hase/bin:/home/hase/.local/bin:/usr/local/pyenv/shims:/usr/local/pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
MANDATORY_PATH=/usr/share/gconf/mate.mandatory.path
PYTHONPATH=/home/hase/.pyenv/versions/3.4.1/lib/python3.4:/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tensorflow/contrib/:
hase@hase-desktop:/$ sudo env |grep PATH
[sudo] hase のパスワード:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
hase@hase-desktop:/$

と大幅に違うことが判明・・・

python3.5 uninstall(remove)させて
libhdf5-dev を 先にinstall
その後にlibhdf5-devをapt-get させてpip3 install h5pyを更に実行する。
installは成功した。
が、keras.Modelがないっていうのは同じ・・・

python 3.5を削除しましたが変化がありません。
sudo apt --purge remove python3.5
をやってもだめでした。

pythonpathがちゃんとなっていないことにたどりつき、
>>> import sys
>>> print(sys.import)
の結果が下図。

>>> import sys
>>> print(sys.path)
['', '/home/hase/.pyenv/versions/3.4.1/lib/python3.4', '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tensorflow/contrib', '/home/hase/.keras', '/home/hase/Documents/deep-learning-models-master/~/virtualenv/py-keras/lib/python3.4/site-packages', '/home/hase/Documents/deep-learning-models-master', '/home/hase/.pyenv/versions/3.4.1/lib/python34.zip', '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/plat-linux', '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/lib-dynload', '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages']
>>>

deep-learning-models-masterから後ろが切れていないで~/virtualenv・・・になっているし、ここがkerasへのPATHだし。ということでここを書いてある場所を探して修正する必要がある。

~と書いたのでだめだったようで、/home/haseに変更すると修正された。


>>> import sys
>>> print(sys.path)
['', '/home/hase/.pyenv/versions/3.4.1/lib/python3.4', '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tensorflow/contrib', '/home/hase/virtualenv/py-keras/lib/python3.4/site-packages', '/home/hase', '/home/hase/.pyenv/versions/3.4.1/lib/python34.zip', '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/plat-linux', '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/lib-dynload', '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages']
>>>

が、まだ同じエラーが出る!

hase@hase-desktop:~/Documents/deep-learning-models-master$ python3 inception_v3.py
Traceback (most recent call last):
File "inception_v3.py", line 19, in <module>
from keras.models import Model
ImportError: No module named 'keras.models'
hase@hase-desktop:~/Documents/deep-learning-models-master$


>>> sys.modules
{'os': <module 'os' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/os.py'>, '_weakref': <module '_weakref' (built-in)>, '_bootlocale': <module '_bootlocale' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/_bootlocale.py'>, 'io': <module 'io' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/io.py'>, 'sys': <module 'sys' (built-in)>, 'google': <module 'google'>, '_sysconfigdata': <module '_sysconfigdata' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/_sysconfigdata.py'>, 'posix': <module 'posix' (built-in)>, '_sitebuiltins': <module '_sitebuiltins' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/_sitebuiltins.py'>, 'site': <module 'site' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site.py'>, 'encodings': <module 'encodings' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/encodings/__init__.py'>, 'mpl_toolkits': <module 'mpl_toolkits'>, 'atexit': <module 'atexit' (built-in)>, 'stat': <module 'stat' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/stat.py'>, '_collections_abc': <module '_collections_abc' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/_collections_abc.py'>, '_stat': <module '_stat' (built-in)>, 'types': <module 'types' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/types.py'>, 'encodings.utf_8': <module 'encodings.utf_8' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/encodings/utf_8.py'>, 'signal': <module 'signal' (built-in)>, '_thread': <module '_thread' (built-in)>, 'abc': <module 'abc' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/abc.py'>, 'posixpath': <module 'posixpath' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/posixpath.py'>, 'sysconfig': <module 'sysconfig' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/sysconfig.py'>, 'zipimport': <module 'zipimport' (built-in)>, '_frozen_importlib': <module '_frozen_importlib' (frozen)>, '__main__': <module '__main__' (built-in)>, '_weakrefset': <module '_weakrefset' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/_weakrefset.py'>, 'marshal': <module 'marshal' (built-in)>, 'genericpath': <module 'genericpath' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/genericpath.py'>, 'builtins': <module 'builtins' (built-in)>, '_warnings': <module '_warnings' (built-in)>, 'encodings.aliases': <module 'encodings.aliases' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/encodings/aliases.py'>, '_codecs': <module '_codecs' (built-in)>, '_locale': <module '_locale' (built-in)>, 'errno': <module 'errno' (built-in)>, 'encodings.latin_1': <module 'encodings.latin_1' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/encodings/latin_1.py'>, '_imp': <module '_imp' (built-in)>, 'os.path': <module 'posixpath' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/posixpath.py'>, '_io': <module 'io' (built-in)>, 'codecs': <module 'codecs' from '/home/hase/.pyenv/versions/3.4.1/lib/python3.4/codecs.py'>}
>>>
ここの中にいない・・・keras


>>> import keras
>>> keras.__path__
/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tensorflow/contrib/keras
と出ているので、kerasの場所が違うようだ。
.bashrcでpath設定を上記に変更。

ここまでやってもエラーが止まらないので片っ端からkerasを削除。
virtualenvの下にあるもの、単独であるもの、 sudo rm -r ディレクトリ名 

すべて消したあとに再インストー
sudo pip3 install keras

hase@hase-desktop:~/Documents/deep-learning-models-master$ python3 inception_v3.py
Using TensorFlow backend.
Traceback (most recent call last):
File "inception_v3.py", line 20, in <module>
from keras.models import Model
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/__init__.py", line 3, in <module>
from . import activations
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/activations.py", line 6, in <module>
from .engine import Layer
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/engine/__init__.py", line 8, in <module>
from .training import Model
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/engine/training.py", line 24, in <module>
from .. import callbacks as cbks
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/callbacks.py", line 26, in <module>
from tensorflow.contrib.tensorboard.plugins import projector
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tensorflow/contrib/__init__.py", line 37, in <module>
from tensorflow.contrib import keras
ImportError: cannot import name 'keras'

あれれ、またエラー・・・・

再度下記を行うが・・・

$ python3 -c "import keras"
Using TensorFlow backend.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/__init__.py", line 3, in <module>
from . import activations
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/activations.py", line 6, in <module>
from .engine import Layer
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/engine/__init__.py", line 8, in <module>
from .training import Model
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/engine/training.py", line 24, in <module>
from .. import callbacks as cbks
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/callbacks.py", line 26, in <module>
from tensorflow.contrib.tensorboard.plugins import projector
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tensorflow/contrib/__init__.py", line 37, in <module>
from tensorflow.contrib import keras
ImportError: cannot import name 'keras'
hase@hase-desktop:~/Documents/deep-learning-models-master$


2017/5/20
再installすることとした。

logを列挙すると
hase@hase-desktop:~$ pyenv install 3.4.1
pyenv: /home/hase/.pyenv/versions/3.4.1 already exists
continue with installation? (y/N) y
Downloading Python-3.4.1.tar.xz...
-> https://www.python.org/ftp/python/3.4.1/Python-3.4.1.tar.xz
Installing Python-3.4.1...
patching file ./Lib/ssl.py
patching file ./Modules/_ssl.c
Hunk #1 succeeded at 2014 (offset -2 lines).
Hunk #2 succeeded at 4066 (offset -7 lines).
Installed Python-3.4.1 to /home/hase/.pyenv/versions/3.4.1

hase@hase-desktop:~$ python -V
Python 3.4.1
hase@hase-desktop:~$ sudo apt-get install python3-pip python3-dev
[sudo] hase のパスワード:
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
dh-python libpython3-dev libpython3.5-dev python3 python3-pkg-resources
python3-setuptools python3-wheel python3.5 python3.5-dev
提案パッケージ:
python3-doc python3-tk python3-venv python-setuptools-doc python3.5-venv
python3.5-doc
以下のパッケージが新たにインストールされます:
dh-python libpython3-dev libpython3.5-dev python3 python3-dev python3-pip
python3-pkg-resources python3-setuptools python3-wheel python3.5
python3.5-dev
アップグレード: 0 個、新規インストール: 11 個、削除: 0 個、保留: 0 個。
37.5 MB のアーカイブを取得する必要があります。
この操作後に追加で 49.2 MB のディスク容量が消費されます。
続行しますか? [Y/n] y
取得:1 http://ports.ubuntu.com xenial-updates/main armhf python3.5 armhf 3.5.2-2ubuntu0~16.04.1 [165 kB]
取得:2 http://ports.ubuntu.com xenial-updates/main armhf dh-python all 2.20151103ubuntu1.1 [74.1 kB]
取得:3 http://ports.ubuntu.com xenial/main armhf python3 armhf 3.5.1-3 [8,748 B]
取得:4 http://ports.ubuntu.com xenial-updates/main armhf libpython3.5-dev armhf 3.5.2-2ubuntu0~16.04.1 [36.5 MB]
取得:5 http://ports.ubuntu.com xenial/main armhf libpython3-dev armhf 3.5.1-3 [6,930 B]
取得:6 http://ports.ubuntu.com xenial-updates/main armhf python3.5-dev armhf 3.5.2-2ubuntu0~16.04.1 [413 kB]
取得:7 http://ports.ubuntu.com xenial/main armhf python3-dev armhf 3.5.1-3 [1,204 B]
取得:8 http://ports.ubuntu.com xenial-updates/universe armhf python3-pip all 8.1.1-2ubuntu0.4 [109 kB]
取得:9 http://ports.ubuntu.com xenial/main armhf python3-pkg-resources all 20.7.0-1 [79.0 kB]
取得:10 http://ports.ubuntu.com xenial/main armhf python3-setuptools all 20.7.0-1 [88.0 kB]
取得:11 http://ports.ubuntu.com xenial/universe armhf python3-wheel all 0.29.0-1 [48.1 kB]
37.5 MB を 53秒 で取得しました (707 kB/s)
以前に未選択のパッケージ python3.5 を選択しています。
(データベースを読み込んでいます ... 現在 179933 個のファイルとディレクトリがインストールされています。)
.../python3.5_3.5.2-2ubuntu0~16.04.1_armhf.deb を展開する準備をしています ...
python3.5 (3.5.2-2ubuntu0~16.04.1) を展開しています...
以前に未選択のパッケージ dh-python を選択しています。
.../dh-python_2.20151103ubuntu1.1_all.deb を展開する準備をしています ...
dh-python (2.20151103ubuntu1.1) を展開しています...
以前に未選択のパッケージ python3 を選択しています。
.../python3_3.5.1-3_armhf.deb を展開する準備をしています ...
python3 (3.5.1-3) を展開しています...
以前に未選択のパッケージ libpython3.5-dev:armhf を選択しています。
.../libpython3.5-dev_3.5.2-2ubuntu0~16.04.1_armhf.deb を展開する準備をしています ...
libpython3.5-dev:armhf (3.5.2-2ubuntu0~16.04.1) を展開しています...
以前に未選択のパッケージ libpython3-dev:armhf を選択しています。
.../libpython3-dev_3.5.1-3_armhf.deb を展開する準備をしています ...
libpython3-dev:armhf (3.5.1-3) を展開しています...
以前に未選択のパッケージ python3.5-dev を選択しています。
.../python3.5-dev_3.5.2-2ubuntu0~16.04.1_armhf.deb を展開する準備をしています ...
python3.5-dev (3.5.2-2ubuntu0~16.04.1) を展開しています...
以前に未選択のパッケージ python3-dev を選択しています。
.../python3-dev_3.5.1-3_armhf.deb を展開する準備をしています ...
python3-dev (3.5.1-3) を展開しています...
以前に未選択のパッケージ python3-pip を選択しています。
.../python3-pip_8.1.1-2ubuntu0.4_all.deb を展開する準備をしています ...
python3-pip (8.1.1-2ubuntu0.4) を展開しています...
以前に未選択のパッケージ python3-pkg-resources を選択しています。
.../python3-pkg-resources_20.7.0-1_all.deb を展開する準備をしています ...
python3-pkg-resources (20.7.0-1) を展開しています...
以前に未選択のパッケージ python3-setuptools を選択しています。
.../python3-setuptools_20.7.0-1_all.deb を展開する準備をしています ...
python3-setuptools (20.7.0-1) を展開しています...
以前に未選択のパッケージ python3-wheel を選択しています。
.../python3-wheel_0.29.0-1_all.deb を展開する準備をしています ...
python3-wheel (0.29.0-1) を展開しています...
desktop-file-utils (0.22-1ubuntu5.1) のトリガを処理しています ...
bamfdaemon (0.5.3~bzr0+16.04.20160824-0ubuntu1) のトリガを処理しています ...
Rebuilding /usr/share/applications/bamf-2.index...
mime-support (3.59ubuntu1) のトリガを処理しています ...
man-db (2.7.5-1) のトリガを処理しています ...
python3.5 (3.5.2-2ubuntu0~16.04.1) を設定しています ...
libpython3.5-dev:armhf (3.5.2-2ubuntu0~16.04.1) を設定しています ...
libpython3-dev:armhf (3.5.1-3) を設定しています ...
python3.5-dev (3.5.2-2ubuntu0~16.04.1) を設定しています ...
python3 (3.5.1-3) を設定しています ...
running python rtupdate hooks for python3.5...
running python post-rtupdate hooks for python3.5...
python3-dev (3.5.1-3) を設定しています ...
python3-pip (8.1.1-2ubuntu0.4) を設定しています ...
python3-pkg-resources (20.7.0-1) を設定しています ...
python3-setuptools (20.7.0-1) を設定しています ...
python3-wheel (0.29.0-1) を設定しています ...
dh-python (2.20151103ubuntu1.1) を設定しています ...
hase@hase-desktop:~$ sudo pip3 install tensorflow-1.1.0-cp34-cp34m-linux_armv7l.whl
The directory '/home/hase/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/hase/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
tensorflow-1.1.0-cp34-cp34m-linux_armv7l.whl is not a supported wheel on this platform.
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
hase@hase-desktop:~$ pip -V
pip 9.0.1 from /home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages (python 3.4)
hase@hase-desktop:~$ pip3 install tensorflow-1.1.0-cp34-cp34m-linux_armv7l.whlProcessing ./tensorflow-1.1.0-cp34-cp34m-linux_armv7l.whl
Requirement already satisfied: six>=1.10.0 in ./.pyenv/versions/3.4.1/lib/python3.4/site-packages (from tensorflow==1.1.0)
Requirement already satisfied: protobuf>=3.2.0 in ./.pyenv/versions/3.4.1/lib/python3.4/site-packages (from tensorflow==1.1.0)
Requirement already satisfied: wheel>=0.26 in ./.pyenv/versions/3.4.1/lib/python3.4/site-packages (from tensorflow==1.1.0)
Requirement already satisfied: numpy>=1.11.0 in ./.pyenv/versions/3.4.1/lib/python3.4/site-packages (from tensorflow==1.1.0)
Requirement already satisfied: werkzeug>=0.11.10 in ./.pyenv/versions/3.4.1/lib/python3.4/site-packages (from tensorflow==1.1.0)
Requirement already satisfied: setuptools in ./.pyenv/versions/3.4.1/lib/python3.4/site-packages (from protobuf>=3.2.0->tensorflow==1.1.0)
Installing collected packages: tensorflow
Successfully installed tensorflow-1.1.0
hase@hase-desktop:~$ sudo pip3 uninstall mock
The directory '/home/hase/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Cannot uninstall requirement mock, not installed
The directory '/home/hase/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
hase@hase-desktop:~$ sudo pip3 install mock
The directory '/home/hase/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/hase/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting mock
Downloading mock-2.0.0-py2.py3-none-any.whl (56kB)
100% |████████████████████████████████| 61kB 2.0MB/s
Collecting six>=1.9 (from mock)
Downloading six-1.10.0-py2.py3-none-any.whl
Collecting pbr>=0.11 (from mock)
Downloading pbr-3.0.1-py2.py3-none-any.whl (99kB)
100% |████████████████████████████████| 102kB 1.6MB/s
Installing collected packages: six, pbr, mock
Successfully installed mock pbr six
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
hase@hase-desktop:~$ sudo pip install --upgrade pip
The directory '/home/hase/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/hase/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 218kB/s
Installing collected packages: pip
Found existing installation: pip 8.1.1
Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
Successfully installed pip-9.0.1
hase@hase-desktop:~$ apt-get install keras
E: ロックファイル /var/lib/dpkg/lock をオープンできません - open (13: 許可がありません)
E: 管理用ディレクトリ (/var/lib/dpkg/) をロックできません。root 権限で実行していますか?
hase@hase-desktop:~$ sudo apt-get install keras
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
E: パッケージ keras が見つかりません
hase@hase-desktop:~$ pip install keras
Collecting keras
Requirement already satisfied: pyyaml in ./.pyenv/versions/3.4.1/lib/python3.4/site-packages (from keras)
Requirement already satisfied: theano in ./.pyenv/versions/3.4.1/lib/python3.4/site-packages (from keras)
Requirement already satisfied: six in ./.pyenv/versions/3.4.1/lib/python3.4/site-packages (from keras)
Requirement already satisfied: numpy>=1.9.1 in ./.pyenv/versions/3.4.1/lib/python3.4/site-packages (from theano->keras)
Requirement already satisfied: scipy>=0.14 in ./.pyenv/versions/3.4.1/lib/python3.4/site-packages (from theano->keras)
Installing collected packages: keras
Successfully installed keras-2.0.4
hase@hase-desktop:~$ cd Documents
hase@hase-desktop:~/Documents$ ls
SimpleCV-1.3.deb deep-learning-models-master.zip raspberrypi
deep-learning-models-master imagenet_class_index.json
hase@hase-desktop:~/Documents$ cd deep-learning-models-master
hase@hase-desktop:~/Documents/deep-learning-models-master$ ls
LICENSE
README.md
audio_conv_utils.py
imagenet_class_index.json
imagenet_utils.py
inception_v3.py
inception_v3_weights_tf_dim_ordering_tf_kernels.h5
inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5
inception_v3_weights_th_dim_ordering_th_kernels.h5
inception_v3_weights_th_dim_ordering_th_kernels_notop.h5
music_tagger_crnn.py
resnet50.py
vgg16.py
vgg19.py
xception.py
hase@hase-desktop:~/Documents/deep-learning-models-master$ 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
Traceback (most recent call last):
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1039, in _do_call
return fn(*args)
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1021, in _run_fn
status, run_metadata)
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/contextlib.py", line 66, in __exit__
next(self.gen)
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InternalError: Could not allocate ndarray

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "inception_v3.py", line 400, in <module>
model = InceptionV3(include_top=True, weights='imagenet')
File "inception_v3.py", line 386, in InceptionV3
model.load_weights(weights_path)
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/engine/topology.py", line 2538, in load_weights
load_weights_from_hdf5_group(f, self.layers)
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/engine/topology.py", line 2970, in load_weights_from_hdf5_group
K.batch_set_value(weight_value_tuples)
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/keras/backend/tensorflow_backend.py", line 2153, in batch_set_value
get_session().run(assign_ops, feed_dict=feed_dict)
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 778, in run
run_metadata_ptr)
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 982, in _run
feed_dict_string, options, run_metadata)
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1032, in _do_run
target_list, options, run_metadata)
File "/home/hase/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1052, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InternalError: Could not allocate ndarray
hase@hase-desktop:~/Documents/deep-learning-models-master$


あれま、またエラーで止まった・・・今度はkerasじゃないのでちょっと進歩。

keras でつまずく

前回にblogを書いてからもinstallは続けていたのですが、keras でエラーを吐かれてつまずき中。


tensorflowを入れてkeras が最後だったのですが。

pathが悪いかなんなのか?

とにかく止まって1.5週間です。

OPEN CV 画像認識 その1

raspberry PI 3を3月末に購入して、カメラなどつけてはみたが今回は画像認識ソフトにチャレンジ。

特に目的はないのだけれど、画像認識を試してみたくて先人に習いながらinstall

 

必要なもの

raspberryPI3

ubuntuMATE 16.04

USBカメラ(OPENCVのインストールには不要)

キーボード、マウス、モニター

 

起動時にtightvcnsereverを入れていたため、メモリが不足したのでこれは一旦メモリからは抜いておく(-kill オプションを使用)

 

入れる準備は参考のURLを参照(入れるためにはコマンドだけ打てばよい)

pythonは2にするか3にするかは自分で決める。今回は3にした。

 

make -j4

を実施。

何度か途中でメモリがいっぱいになりハングアップしたので、CTRL+Cで途中で止め、再開して100%になるまで make する。途中で止めてもいったん作ったものは残っているのでできたところは飛ばして再開してくれる。

makeが終わったらinstallしてみる。

 

GW最終日。暇なんだな>おれ

 

#結局、installまではできた。OPEN CVは完成した。

が、画像認識まではまだまだ入れなくてはいけないものがあることがわかり、

本日はここまで。

 

<参考にしたweb>

www.pyimagesearch.com