私的AI研究会 > NCAppZoo1

Neural Compute Application Zoo (ncappzoo)

 Neural Compute Application ZooというGitHubにて公開されているサイトから Neural Compute Stick 2 とRaspberryPi でディープラーニングの推論アプリケーションを実習する。(その1)

※ 最終更新:2021/02/28 

「Neural Compute Application Zoo」の準備

Raspberry Pi 上で直接インストール

  1. GitHub から一括ダウンロード
    pi@raspberrypi:~ $ git clone https://github.com/movidius/ncappzoo.git
    Cloning into 'ncappzoo'...
    remote: Enumerating objects: 2, done.
    remote: Counting objects: 100% (2/2), done.
    remote: Compressing objects: 100% (2/2), done.
    remote: Total 7160 (delta 0), reused 0 (delta 0), pack-reused 7158
    Receiving objects: 100% (7160/7160), 576.59 MiB | 2.08 MiB/s, done.
    Resolving deltas: 100% (4456/4456), done.
    ディレクトリ「ncappzoo」が作成される。
    pi@raspberrypi-mas:~ $ ls
    Bookshelf  Documents  Music     Public     Videos  cq        work-opencv
    Desktop    Downloads  Pictures  Templates  build   ncappzoo  workspace
  2. モデル オプティマイザーをインストール & 環境設定
    Raspbian OS 用の OpenVINO™ ツールキットのインテル®ディストリビューションには、モデルオプティマイザは含まれていない。ncappzooを使用するには、OpenVINO™ディープ ラーニング開発ツールキット (DLDT) のオープンソース バージョンを複製し、そのバージョンのモデル オプティマイザーを使用する必要がある
    pi@raspberrypi:~ $ git clone https://github.com/opencv/dldt.git
    Cloning into 'dldt'...
    remote: Enumerating objects: 99045, done.
    remote: Total 99045 (delta 0), reused 0 (delta 0), pack-reused 99045
    Receiving objects: 100% (99045/99045), 111.09 MiB | 1.60 MiB/s, done.
    Resolving deltas: 100% (71833/71833), done.
    Checking out files: 100% (10335/10335), done.
    
    pi@raspberrypi:~ $ cd dldt/model-optimizer
    pi@raspberrypi:~/dldt/model-optimizer $ ls
    CMakeLists.txt  install_prerequisites  mo_kaldi.py  requirements.txt        requirements_mxnet.txt  setup.py
    README.md       mo                     mo_mxnet.py  requirements_caffe.txt  requirements_onnx.txt   telemetry
    automation      mo.py                  mo_onnx.py   requirements_dev.txt    requirements_tf.txt
    extensions      mo_caffe.py            mo_tf.py     requirements_kaldi.txt  requirements_tf2.txt
    
    pi@raspberrypi:~/dldt/model-optimizer $ pip3 install -r requirements_tf.txt
    Ignoring tensorflow: markers 'python_version >= "3.8"' don't match your environment
    Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
    Collecting tensorflow<2.0,>=1.15.2 (from -r requirements_tf.txt (line 1))
      Could not find a version that satisfies the requirement tensorflow<2.0,>=1.15.2 (from -r requirements_tf.txt (line 1)) (from versions: 0.11.0, 1.12.0, 1.13.1, 1.14.0)
    No matching distribution found for tensorflow<2.0,>=1.15.2 (from -r requirements_tf.txt (line 1))
    
    pi@raspberrypi:~/dldt/model-optimizer $ pip3 install -r requirements_caffe.txt
    Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
    Collecting networkx>=1.11 (from -r requirements_caffe.txt (line 1))
      Downloading https://files.pythonhosted.org/packages/9b/cd/dc52755d30ba41c60243235460961fc28022e5b6731f16c268667625baea/networkx-2.5-py3-none-any.whl (1.6MB)
        100% |████████████████████████████████| 1.6MB 273kB/s 
     Requirement already satisfied: numpy>=1.14.0 in /usr/lib/python3/dist-packages (from -r requirements_caffe.txt (line 2)) (1.16.2)
    Collecting protobuf>=3.6.1 (from -r requirements_caffe.txt (line 3))
      Downloading https://files.pythonhosted.org/packages/81/d4/a8a31a326ee60e295e5d7477d93d8f6ceee98246c1a7381afc817a91d893/protobuf-3.14.0-py2.py3-none-any.whl (173kB)
        100% |████████████████████████████████| 174kB 2.2MB/s 
    Collecting test-generator==0.1.1 (from -r requirements_caffe.txt (line 4))
      Downloading https://files.pythonhosted.org/packages/4a/52/e5eec4d926eb466844eaeeaac84af5372e946dd520fb2b6adf3388e620b0/test_generator-0.1.1-py2.py3-none-any.whl
    Collecting defusedxml>=0.5.0 (from -r requirements_caffe.txt (line 5))
      Downloading https://files.pythonhosted.org/packages/06/74/9b387472866358ebc08732de3da6dc48e44b0aacd2ddaa5cb85ab7e986a2/defusedxml-0.6.0-py2.py3-none-any.whl
    Requirement already satisfied: requests>=2.20.0 in /usr/lib/python3/dist-packages (from -r requirements_caffe.txt (line 6)) (2.21.0)
    Requirement already satisfied: decorator>=4.3.0 in /usr/lib/python3/dist-packages (from networkx>=1.11->-r requirements_caffe.txt (line 1)) (4.3.0)
    Requirement already satisfied: six>=1.9 in /usr/lib/python3/dist-packages (from protobuf>=3.6.1->-r requirements_caffe.txt (line 3)) (1.12.0)
    Installing collected packages: networkx, protobuf, test-generator, defusedxml
    Successfully installed defusedxml-0.6.0 networkx-2.5 protobuf-3.14.0 test-generator-0.1.1
    
    pi@raspberrypi:~/dldt/model-optimizer $ export PATH=~/dldt/model-optimizer:$PATH
    
    pi@raspberrypi:~/dldt/model-optimizer $ export PYTHONPATH=~/dldt/model-optmizer:$PYTHONPATH
  3. ソフトウェアの依存関係を確認 (コマンドがサイトの記述とは異なっている)
    pi@raspberrypi:~ $ cd ~/ncappzoo
    pi@raspberrypi-mas:~/ncappzoo $ ls
    CONTRIBUTING.md  MAKEFILE_GUIDANCE.md  OWNERS     apps   data  install_deps.sh  omz     tensorflow
    LICENSE          Makefile              README.md  caffe  docs  networks         shared
    
    pi@raspberrypi:~/ncappzoo $ ./install_deps.sh
    Checking system dependencies...\n
    Intel Distribution of OpenVINO is installed.
    Python3, pip3, git, and essential compilers are installed.
    networkx          2.5        
    Minimal Python packages installed
    ncappzoo is ready.
    環境はできたようだ。↑
  4. 必要なツールのインストール
    pi@raspberrypi:~/ncappzoo/apps $ pip3 install pyyaml --user
    Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
    Collecting pyyaml
      Downloading https://files.pythonhosted.org/packages/a0/a4/d63f2d7597e1a4b55aa3b4d6c5b029991d3b824b5bd331af8d4ab1ed687d/PyYAML-5.4.1.tar.gz (175kB)
        100% |████████████████████████████████| 184kB 614kB/s 
      Installing build dependencies ... done
    Building wheels for collected packages: pyyaml
      Running setup.py bdist_wheel for pyyaml ... done
      Stored in directory: /home/pi/.cache/pip/wheels/2a/d4/92/cf299bdf4162957ca8126b46e913e29f76a4f17ca762c45028
    Successfully built pyyaml
    Installing collected packages: pyyaml
    Successfully installed pyyaml-5.4.1
  5. 後は該当するフォルダで make を実行して必要なファイルを構成する。
    &color(red){エラーとなって構成できないものも多い。ソースファイルは API の変更に伴い若干の修正を要する。}

Ubuntu2004LTS (Hyper-V上) 上で実行してできたファイルを Raspberry Pi 上にコピーする。

  1. GitHub から一括ダウンロード
    [setupvars.sh] OpenVINO environment initialized
    mizutu@ubuntu2004dk:~$ git clone https://github.com/movidius/ncappzoo.git
    Cloning into 'ncappzoo'...
    remote: Enumerating objects: 2, done.
    remote: Counting objects: 100% (2/2), done.
    remote: Compressing objects: 100% (2/2), done.
    remote: Total 7160 (delta 0), reused 0 (delta 0), pack-reused 7158
    Receiving objects: 100% (7160/7160), 576.59 MiB | 13.63 MiB/s, done.
    Resolving deltas: 100% (4456/4456), done.
    ディレクトリ「ncappzoo」が作成される。
    mizutu@ubuntu2004dk:~$ ls
    inference_engine_demos_build    openvino2.txt    work          ビデオ
    inference_engine_samples_build  openvino3.txt    ダウンロード  ピクチャ
    linux-vm-tools                  openvino4.txt    テンプレート  ミュージック
    ncappzoo                        openvino_models  デスクトップ  公開
    openvino.txt                    shared-drives    ドキュメント
  2. ソフトウェアの依存関係を確認 (コマンドがサイトの記述とは異なっている)
    mizutu@ubuntu2004dk:~$ cd ~/ncappzoo
    mizutu@ubuntu2004dk:~/ncappzoo$ ls
    CONTRIBUTING.md       Makefile   apps   docs             omz
    LICENSE               OWNERS     caffe  install_deps.sh  shared
    MAKEFILE_GUIDANCE.md  README.md  data   networks         tensorflow
    
    mizutu@ubuntu2004dk:~/ncappzoo$ ./install_deps.sh
    Checking system dependencies...\n
    Intel Distribution of OpenVINO is installed.
    Python3, pip3, git, and essential compilers are installed.
    networkx               2.5                 
    tensorflow             2.3.2               
    tensorflow-estimator   2.3.0               
    Minimal Python packages installed
    ncappzoo is ready.
    こちらの方が簡単。↑
  3. 必要なツールのインストール(インストール済みのよう)
    mizutu@ubuntu2004dk:~/ncappzoo$ pip3 install pyyaml --user
    Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (5.3.1)
  4. 後は該当するフォルダで make を実行して必要なファイルを構成する。
    ちなみに make all ですべての構成を試みたが途中エラーで停止した。個別に確認しながら make することにする。

「ncappzoo」ディレクトリの内容 (make 実行結果)

更新履歴

 

参考資料

 

Last-modified: 2021-03-16 (火) 13:10:50