Raspberry pi 4 model B を試す
RPI4 なら、いろいろできるかもしれない?
試してみます。
Tensorflow を動かす
$ sudo apt install libatlas-base-dev
$ pip3 install tensorflow --user
動作確認まで
$ python3 Python 3.7.3 (default, Apr 3 2019, 05:39:12) [GCC 8.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf WARNING: Logging before flag parsing goes to stderr. W0711 11:25:13.680072 3069655760 deprecation_wrapper.py:118] From /home/kiyo/.local/lib/python3.7/site-packages/tensorflow/__init__.py:98: The name tf.AUTO_REUSE is deprecated. Please use tf.compat.v1.AUTO_REUSE instead. W0711 11:25:13.680785 3069655760 deprecation_wrapper.py:118] From /home/kiyo/.local/lib/python3.7/site-packages/tensorflow/__init__.py:98: The name tf.AttrValue is deprecated. Please use tf.compat.v1.AttrValue instead. W0711 11:25:13.681129 3069655760 deprecation_wrapper.py:118] From /home/kiyo/.local/lib/python3.7/site-packages/tensorflow/__init__.py:98: The name tf.COMPILER_VERSION is deprecated. Please use tf.version.COMPILER_VERSION instead. W0711 11:25:13.681412 3069655760 deprecation_wrapper.py:118] From /home/kiyo/.local/lib/python3.7/site-packages/tensorflow/__init__.py:98: The name tf.CXX11_ABI_FLAG is deprecated. Please use tf.sysconfig.CXX11_ABI_FLAG instead. W0711 11:25:13.681687 3069655760 deprecation_wrapper.py:118] From /home/kiyo/.local/lib/python3.7/site-packages/tensorflow/__init__.py:98: The name tf.ConditionalAccumulator is deprecated. Please use tf.compat.v1.ConditionalAccumulator instead. >>> hello = tf.constant('Hello, TensorFlow!') >>> sess = tf.Session() >>> print(sess.run(hello)) b'Hello, TensorFlow!' >>>
Keras Mnist Fashion を試す
試しました。 動きました。
Darknet
$ git clone https://github.com/pjreddie/darknet $ cd darknet $ make $ ./darknet detector test cfg/coco.data cfg/yolov2.cfg yolov2.weights data/person.jpg layer filters size input output 0 conv 32 3 x 3 / 1 608 x 608 x 3 -> 608 x 608 x 32 0.639 BFLOPs 1 max 2 x 2 / 2 608 x 608 x 32 -> 304 x 304 x 32 2 conv 64 3 x 3 / 1 304 x 304 x 32 -> 304 x 304 x 64 3.407 BFLOPs 3 max 2 x 2 / 2 304 x 304 x 64 -> 152 x 152 x 64 4 conv 128 3 x 3 / 1 152 x 152 x 64 -> 152 x 152 x 128 3.407 BFLOPs 5 conv 64 1 x 1 / 1 152 x 152 x 128 -> 152 x 152 x 64 0.379 BFLOPs 6 conv 128 3 x 3 / 1 152 x 152 x 64 -> 152 x 152 x 128 3.407 BFLOPs 7 max 2 x 2 / 2 152 x 152 x 128 -> 76 x 76 x 128 8 conv 256 3 x 3 / 1 76 x 76 x 128 -> 76 x 76 x 256 3.407 BFLOPs 9 conv 128 1 x 1 / 1 76 x 76 x 256 -> 76 x 76 x 128 0.379 BFLOPs 10 conv 256 3 x 3 / 1 76 x 76 x 128 -> 76 x 76 x 256 3.407 BFLOPs 11 max 2 x 2 / 2 76 x 76 x 256 -> 38 x 38 x 256 12 conv 512 3 x 3 / 1 38 x 38 x 256 -> 38 x 38 x 512 3.407 BFLOPs 13 conv 256 1 x 1 / 1 38 x 38 x 512 -> 38 x 38 x 256 0.379 BFLOPs 14 conv 512 3 x 3 / 1 38 x 38 x 256 -> 38 x 38 x 512 3.407 BFLOPs 15 conv 256 1 x 1 / 1 38 x 38 x 512 -> 38 x 38 x 256 0.379 BFLOPs 16 conv 512 3 x 3 / 1 38 x 38 x 256 -> 38 x 38 x 512 3.407 BFLOPs 17 max 2 x 2 / 2 38 x 38 x 512 -> 19 x 19 x 512 18 conv 1024 3 x 3 / 1 19 x 19 x 512 -> 19 x 19 x1024 3.407 BFLOPs 19 conv 512 1 x 1 / 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BFLOPs 20 conv 1024 3 x 3 / 1 19 x 19 x 512 -> 19 x 19 x1024 3.407 BFLOPs 21 conv 512 1 x 1 / 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BFLOPs 22 conv 1024 3 x 3 / 1 19 x 19 x 512 -> 19 x 19 x1024 3.407 BFLOPs 23 conv 1024 3 x 3 / 1 19 x 19 x1024 -> 19 x 19 x1024 6.814 BFLOPs 24 conv 1024 3 x 3 / 1 19 x 19 x1024 -> 19 x 19 x1024 6.814 BFLOPs 25 route 16 26 conv 64 1 x 1 / 1 38 x 38 x 512 -> 38 x 38 x 64 0.095 BFLOPs 27 reorg / 2 38 x 38 x 64 -> 19 x 19 x 256 28 route 27 24 29 conv 1024 3 x 3 / 1 19 x 19 x1280 -> 19 x 19 x1024 8.517 BFLOPs 30 conv 425 1 x 1 / 1 19 x 19 x1024 -> 19 x 19 x 425 0.314 BFLOPs 31 detection mask_scale: Using default '1.000000' Loading weights from yolov2.weights...Done! data/person.jpg: Predicted in 71.214195 seconds. horse: 82% dog: 86% person: 86% $ wget https://pjreddie.com/media/files/yolov2-tiny-voc.weights $ ./darknet detector test cfg/voc.data cfg/yolov2-tiny-voc.cfg yolov2-tiny-voc.weights data/dog.jpg
なかなか遅いですね。
Darknet nnpack
python3 に書き換えて実行するのだが、先に、
sudo apt-get -y install re2c
しておく。
コンパイルまで
$ sudo pip3 install --upgrade git+https://github.com/Maratyszcza/PeachPy $ sudo pip3 install --upgrade git+https://github.com/Maratyszcza/confu $ cd $ git clone https://github.com/ninja-build/ninja.git $ cd ninja $ git checkout release $ ./configure.py --bootstrap $ export NINJA_PATH=$PWD $ sudo apt-get install clang $ Install NNPACK-darknet $ cd $ git clone https://github.com/digitalbrain79/NNPACK-darknet.git $ cd NNPACK-darknet $ confu setup $ python3 ./configure.py --backend auto $ $NINJA_PATH/ninja $sudo cp -a lib/* /usr/lib/ $sudo cp include/nnpack.h /usr/include/ $sudo cp deps/pthreadpool/include/pthreadpool.h /usr/include/ $Build darknet-nnpack $ cd $ git clone https://github.com/digitalbrain79/darknet-nnpack.git $ cd darknet-nnpack $ make
weight ファイル
weight ファイルを取得する。
yolov3 はここ。
yolov2 はここ。
実行
$ ./darknet detector test cfg/coco.data cfg/yolov2.cfg yolov2.weights data/person.j pg layer filters size input output 0 conv 32 3 x 3 / 1 608 x 608 x 3 -> 608 x 608 x 32 0.639 BFLOPs 1 max 2 x 2 / 2 608 x 608 x 32 -> 304 x 304 x 32 2 conv 64 3 x 3 / 1 304 x 304 x 32 -> 304 x 304 x 64 3.407 BFLOPs 3 max 2 x 2 / 2 304 x 304 x 64 -> 152 x 152 x 64 4 conv 128 3 x 3 / 1 152 x 152 x 64 -> 152 x 152 x 128 3.407 BFLOPs 5 conv 64 1 x 1 / 1 152 x 152 x 128 -> 152 x 152 x 64 0.379 BFLOPs 6 conv 128 3 x 3 / 1 152 x 152 x 64 -> 152 x 152 x 128 3.407 BFLOPs 7 max 2 x 2 / 2 152 x 152 x 128 -> 76 x 76 x 128 8 conv 256 3 x 3 / 1 76 x 76 x 128 -> 76 x 76 x 256 3.407 BFLOPs 9 conv 128 1 x 1 / 1 76 x 76 x 256 -> 76 x 76 x 128 0.379 BFLOPs 10 conv 256 3 x 3 / 1 76 x 76 x 128 -> 76 x 76 x 256 3.407 BFLOPs 11 max 2 x 2 / 2 76 x 76 x 256 -> 38 x 38 x 256 12 conv 512 3 x 3 / 1 38 x 38 x 256 -> 38 x 38 x 512 3.407 BFLOPs 13 conv 256 1 x 1 / 1 38 x 38 x 512 -> 38 x 38 x 256 0.379 BFLOPs 14 conv 512 3 x 3 / 1 38 x 38 x 256 -> 38 x 38 x 512 3.407 BFLOPs 15 conv 256 1 x 1 / 1 38 x 38 x 512 -> 38 x 38 x 256 0.379 BFLOPs 16 conv 512 3 x 3 / 1 38 x 38 x 256 -> 38 x 38 x 512 3.407 BFLOPs 17 max 2 x 2 / 2 38 x 38 x 512 -> 19 x 19 x 512 18 conv 1024 3 x 3 / 1 19 x 19 x 512 -> 19 x 19 x1024 3.407 BFLOPs 19 conv 512 1 x 1 / 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BFLOPs 20 conv 1024 3 x 3 / 1 19 x 19 x 512 -> 19 x 19 x1024 3.407 BFLOPs 21 conv 512 1 x 1 / 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BFLOPs 22 conv 1024 3 x 3 / 1 19 x 19 x 512 -> 19 x 19 x1024 3.407 BFLOPs 23 conv 1024 3 x 3 / 1 19 x 19 x1024 -> 19 x 19 x1024 6.814 BFLOPs 24 conv 1024 3 x 3 / 1 19 x 19 x1024 -> 19 x 19 x1024 6.814 BFLOPs 25 route 16 26 conv 64 1 x 1 / 1 38 x 38 x 512 -> 38 x 38 x 64 0.095 BFLOPs 27 reorg / 2 38 x 38 x 64 -> 19 x 19 x 256 28 route 27 24 29 conv 1024 3 x 3 / 1 19 x 19 x1280 -> 19 x 19 x1024 8.517 BFLOPs 30 conv 425 1 x 1 / 1 19 x 19 x1024 -> 19 x 19 x 425 0.314 BFLOPs 31 detection mask_scale: Using default '1.000000' Loading weights from yolov2.weights...Done! data/person.jpg: Predicted in 4.701867 seconds. horse: 82% dog: 86% person: 86% $ ./darknet detector test cfg/coco.data cfg/yolov2-tiny.cfg yolov2-tiny.weights data/person.jpg layer filters size input output 0 conv 16 3 x 3 / 1 416 x 416 x 3 -> 416 x 416 x 16 0.150 BFLOPs 1 max 2 x 2 / 2 416 x 416 x 16 -> 208 x 208 x 16 2 conv 32 3 x 3 / 1 208 x 208 x 16 -> 208 x 208 x 32 0.399 BFLOPs 3 max 2 x 2 / 2 208 x 208 x 32 -> 104 x 104 x 32 4 conv 64 3 x 3 / 1 104 x 104 x 32 -> 104 x 104 x 64 0.399 BFLOPs 5 max 2 x 2 / 2 104 x 104 x 64 -> 52 x 52 x 64 6 conv 128 3 x 3 / 1 52 x 52 x 64 -> 52 x 52 x 128 0.399 BFLOPs 7 max 2 x 2 / 2 52 x 52 x 128 -> 26 x 26 x 128 8 conv 256 3 x 3 / 1 26 x 26 x 128 -> 26 x 26 x 256 0.399 BFLOPs 9 max 2 x 2 / 2 26 x 26 x 256 -> 13 x 13 x 256 10 conv 512 3 x 3 / 1 13 x 13 x 256 -> 13 x 13 x 512 0.399 BFLOPs 11 max 2 x 2 / 1 13 x 13 x 512 -> 13 x 13 x 512 12 conv 1024 3 x 3 / 1 13 x 13 x 512 -> 13 x 13 x1024 1.595 BFLOPs 13 conv 512 3 x 3 / 1 13 x 13 x1024 -> 13 x 13 x 512 1.595 BFLOPs 14 conv 425 1 x 1 / 1 13 x 13 x 512 -> 13 x 13 x 425 0.074 BFLOPs 15 detection mask_scale: Using default '1.000000' Loading weights from yolov2-tiny.weights...Done! data/person.jpg: Predicted in 0.652822 seconds. horse: 92% dog: 92% person: 91% $ ./darknet detector test cfg/coco.data cfg/yolov3-tiny.cfg yolov3-tiny.weights data/person.jpg layer filters size input output 0 conv 16 3 x 3 / 1 416 x 416 x 3 -> 416 x 416 x 16 0.150 BFLOPs 1 max 2 x 2 / 2 416 x 416 x 16 -> 208 x 208 x 16 2 conv 32 3 x 3 / 1 208 x 208 x 16 -> 208 x 208 x 32 0.399 BFLOPs 3 max 2 x 2 / 2 208 x 208 x 32 -> 104 x 104 x 32 4 conv 64 3 x 3 / 1 104 x 104 x 32 -> 104 x 104 x 64 0.399 BFLOPs 5 max 2 x 2 / 2 104 x 104 x 64 -> 52 x 52 x 64 6 conv 128 3 x 3 / 1 52 x 52 x 64 -> 52 x 52 x 128 0.399 BFLOPs 7 max 2 x 2 / 2 52 x 52 x 128 -> 26 x 26 x 128 8 conv 256 3 x 3 / 1 26 x 26 x 128 -> 26 x 26 x 256 0.399 BFLOPs 9 max 2 x 2 / 2 26 x 26 x 256 -> 13 x 13 x 256 10 conv 512 3 x 3 / 1 13 x 13 x 256 -> 13 x 13 x 512 0.399 BFLOPs 11 max 2 x 2 / 1 13 x 13 x 512 -> 13 x 13 x 512 12 conv 1024 3 x 3 / 1 13 x 13 x 512 -> 13 x 13 x1024 1.595 BFLOPs 13 conv 256 1 x 1 / 1 13 x 13 x1024 -> 13 x 13 x 256 0.089 BFLOPs 14 conv 512 3 x 3 / 1 13 x 13 x 256 -> 13 x 13 x 512 0.399 BFLOPs 15 conv 255 1 x 1 / 1 13 x 13 x 512 -> 13 x 13 x 255 0.044 BFLOPs 16 yolo 17 route 13 18 conv 128 1 x 1 / 1 13 x 13 x 256 -> 13 x 13 x 128 0.011 BFLOPs 19 upsample 2x 13 x 13 x 128 -> 26 x 26 x 128 20 route 19 8 21 conv 256 3 x 3 / 1 26 x 26 x 384 -> 26 x 26 x 256 1.196 BFLOPs 22 conv 255 1 x 1 / 1 26 x 26 x 256 -> 26 x 26 x 255 0.088 BFLOPs 23 yolo Loading weights from yolov3-tiny.weights...Done! data/person.jpg: Predicted in 0.670556 seconds. horse: 94% dog: 91% dog: 90% person: 86%
なお、yolov3 は、 Segmentation fault
でした。
WEBカメラ
demo で動くし、映像モデルし、エラーも吐かないが、何もディレクトしない。
なんだろうか?