私的AI研究会 > OpenVINO

ゼロから学ぶディープラーニング推論 -OpenVINO™ ツールキットのインストール-

事前準備

OpenVINO™ ツールキットのインストール

OpenVINO™ ツールキットのダウンロード

2020年12月15日現在、OpenVINO™ ツールキットの最新バージョンは 2021.2
公式サイト → Install OpenVINO™ toolkit for Raspbian* OS

● VNCビューアなどで、Raspberry Pi 上のブラウザでオフィシャルサイトのダウンロードページから下記のファイルをダウンロードする。
● URL:https://storage.openvinotoolkit.org/repositories/openvino/packages/2021.2/
● ファイル名:l_openvino_toolkit_runtime_raspbian_p_2021.2.185.tgz
 ※ファイルは「~/Download」ディレクトリに配置される。

pi@raspberrypi:~ $ cd Downloads
pi@raspberrypi:~/Downloads $ ls
l_openvino_toolkit_runtime_raspbian_p_2021.2.185.tgz

OpenVINO™ 本体のインストール

  1. OpenVINO™ ツールキットを展開するフォルダを作成する。
    pi@raspberrypi:~/Downloads $ sudo mkdir -p /opt/intel/openvino
    pi@raspberrypi:~/Downloads $ ls /opt/intel
    openvino
  2. ダウンロードしたファイルを「/opt/intel/openvino」に展開する。
    pi@raspberrypi:~/Downloads $ sudo tar -xf l_openvino_toolkit_runtime_raspbian_p_2021.2.185.tgz --strip 1 -C /opt/intel/openvino
    pi@raspberrypi:~/Downloads $ ls /opt/intel/openvino
    bin  deployment_tools  documentation  inference_engine  install_dependencies  
    licensing  opencv  python
  3. サンプルコードをビルドするために「CMake」をインストールする。
    pi@raspberrypi:~/Downloads $ sudo apt update
    pi@raspberrypi:~/Downloads $ sudo apt install cmake
    パッケージリストを読み込んでいます... 完了
    依存関係ツリーを作成しています                
    状態情報を読み取っています... 完了 
    以下の追加パッケージがインストールされます:
      cmake-data libjsoncpp1 librhash0
       :
    この操作後に追加で 21.6 MB のディスク容量が消費されます。
    続行しますか? [Y/n] y
    取得:1 http://ftp.jaist.ac.jp/raspbian buster/main armhf cmake-data all 3.13.4-1 [1,476 kB]
    取得:2 http://ftp.jaist.ac.jp/raspbian buster/main armhf libjsoncpp1 armhf 1.7.4-3 [66.2 kB]
       :
  4. 環境変数の設定
    setupvars.shスクリプトを実行することにより OpenVINO™ ツールキットが動作するように環境を整える。
    実行して[setupvars.sh] OpenVINO environment initializedと表示されればOK。
    pi@raspberrypi:~/Downloads $ source /opt/intel/openvino/bin/setupvars.sh
    [setupvars.sh] OpenVINO environment initialized
  5. 起動時に自動でコマンド実行するように設定する。
    pi@raspberrypi:~/Downloads $ echo "source /opt/intel/openvino/bin/setupvars.sh" >> ~/.bashrc
  6. USBルールの追加
    現在のユーザーをusersグループに追加する。
    pi@raspberrypi:~/Downloads $ sudo usermod -a -G users "$(whoami)"
    pi@raspberrypi:~/Downloads $ 
  7. 「Neural Compute Stick」を使って OpenVINO™ を実行できるようにスクリプトを実行する。
    udev rules installedと表示されればOK。
    pi@raspberrypi:~/Downloads $ sh /opt/intel/openvino/install_dependencies/install_NCS_udev_rules.sh
    Updating udev rules...
    Udev rules have been successfully installed.
  8. 「Intel© Neural Compute Stick 2」を差し込む。
    以上でオブジェクト検出サンプルをコンパイルして実行し、推論エンジンのインストールを確認する準備が整った。

サンプルのビルドと実行

  1. ユーザーのホームディレクトリに「build」フォルダを作成して移動する。
    pi@raspberrypi:~ $ mkdir build
    pi@raspberrypi:~ $ cd build
  2. オブジェクト検出サンプルをビルドする。(前半)
    pi@raspberrypi:~/build $ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-march=armv7-a" /opt/intel/openvino/deployment_tools/inference_engine/samples/cpp
    -- The C compiler identification is GNU 8.3.0
    -- The CXX compiler identification is GNU 8.3.0
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Looking for C++ include unistd.h
    -- Looking for C++ include unistd.h - found
    -- Looking for C++ include stdint.h
    -- Looking for C++ include stdint.h - found
    -- Looking for C++ include sys/types.h
    -- Looking for C++ include sys/types.h - found
    -- Looking for C++ include fnmatch.h
    -- Looking for C++ include fnmatch.h - found
    -- Looking for strtoll
    -- Looking for strtoll - found
    -- Found InferenceEngine: 
    /opt/intel/openvino/deployment_tools/inference_engine/lib/armv7l/libinference_engine.so (Required is at least version "2.1") 
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/pi/build
  3. 続けてサンプルをビルドするためのコマンド。(後半)
    pi@raspberrypi:~/build $ make -j2 object_detection_sample_ssd
    Scanning dependencies of target format_reader
    Scanning dependencies of target gflags_nothreads_static
    [  9%] Building CXX object thirdparty/gflags/CMakeFiles/gflags_nothreads_static.dir/src/gflags.cc.o
    [ 18%] Building CXX object common/format_reader/CMakeFiles/format_reader.dir/MnistUbyte.cpp.o
    [ 27%] Building CXX object common/format_reader/CMakeFiles/format_reader.dir/bmp.cpp.o
    [ 36%] Building CXX object common/format_reader/CMakeFiles/format_reader.dir/format_reader.cpp.o
    [ 45%] Building CXX object thirdparty/gflags/CMakeFiles/gflags_nothreads_static.dir/src/gflags_reporting.cc.o
    [ 54%] Building CXX object common/format_reader/CMakeFiles/format_reader.dir/opencv_wraper.cpp.o
    [ 63%] Building CXX object thirdparty/gflags/CMakeFiles/gflags_nothreads_static.dir/src/gflags_completions.cc.o
    [ 72%] Linking CXX static library ../../armv7l/Release/lib/libgflags_nothreads.a
    [ 72%] Built target gflags_nothreads_static
    [ 81%] Linking CXX shared library ../../armv7l/Release/lib/libformat_reader.so
    [ 81%] Built target format_reader
    Scanning dependencies of target object_detection_sample_ssd
    [ 90%] Building CXX object object_detection_sample_ssd/CMakeFiles/object_detection_sample_ssd.dir/main.cpp.o
    [100%] Linking CXX executable ../armv7l/Release/object_detection_sample_ssd
    [100%] Built target object_detection_sample_ssd
  4. 学習済み重みファイル をダウンロードする。
    ※オフィシャルサイトを参考に OpenVINO™ ツールキットのバージョンに合ったファイルを https://download.01.org/opencv/ から探してコマンドを変更した。
    pi@raspberrypi:~/build $ wget --no-check-certificate https://download.01.org/opencv/2021/openvinotoolkit/2021.2/open_model_zoo/models_bin/3/face-detection-adas-0001/FP16/face-detection-adas-0001.bin
    --2020-12-18 11:24:17--  https://download.01.org/opencv/2021/openvinotoolkit/2021.2/open_model_zoo/models_bin/3/face-detection-adas-0001/FP16/face-detection-adas-0001.bin
    download.01.org (download.01.org) をDNSに問いあわせています... 23.41.94.105, 2600:140b:8800:28f::4b21, 2600:140b:8800:283::4b21
    download.01.org (download.01.org)|23.41.94.105|:443 に接続しています... 接続しました。
    HTTP による接続要求を送信しました、応答を待っています... 200 OK
    長さ: 2106088 (2.0M) [application/octet-stream]
    `face-detection-adas-0001.bin' に保存中
    
    face-detection-adas-0001.bin     100%[=======================================================>]   2.01M  2.06MB/s 時間 1.0s     
    
    2020-12-18 11:24:20 (2.06 MB/s) - `face-detection-adas-0001.bin' へ保存完了 [2106088/2106088]
  5. 学習済みモデルファイルをダウンロードする。
    pi@raspberrypi:~/build $ wget --no-check-certificate https://download.01.org/opencv/2021/openvinotoolkit/2021.2/open_model_zoo/models_bin/3/face-detection-adas-0001/FP16/face-detection-adas-0001.xml
    --2020-12-18 11:24:42--  https://download.01.org/opencv/2021/openvinotoolkit/2021.2/open_model_zoo/models_bin/3/face-detection-adas-0001/FP16/face-detection-adas-0001.xml
    download.01.org (download.01.org) をDNSに問いあわせています... 23.41.94.105, 2600:140b:8800:28f::4b21, 2600:140b:8800:283::4b21
    download.01.org (download.01.org)|23.41.94.105|:443 に接続しています... 接続しました。
    HTTP による接続要求を送信しました、応答を待っています... 200 OK
    長さ: 225964 (221K) [text/xml]
    `face-detection-adas-0001.xml' に保存中
    
    face-detection-adas-0001.xml     100%[=======================================================>] 220.67K   688KB/s 時間 0.3s     
    
    2020-12-18 11:24:44 (688 KB/s) - `face-detection-adas-0001.xml' へ保存完了 [225964/225964]
  6. ファイルの確認
    pi@raspberrypi:~/build $ ls
    CMakeCache.txt  classification_sample_async   hello_classification             object_detection_sample_ssd
    CMakeFiles      cmake_install.cmake           hello_nv12_input_classification  speech_sample
    Makefile        common                        hello_query_device               style_transfer_sample
    armv7l          face-detection-adas-0001.bin  hello_reshape_ssd                thirdparty
    benchmark_app   face-detection-adas-0001.xml  ngraph_function_creation_sample
  7. ディープラーニング推論する画像を用意し、「build」ディレクトリに「input.jpg」という名前で保存する。
  8. ディープラーニング推論を実行する。
    pi@raspberrypi:~/build $ ./armv7l/Release/object_detection_sample_ssd -m face-detection-adas-0001.xml -d MYRIAD -i input.jpg
    [ INFO ] InferenceEngine: 
            API version ............ 2.1
            Build .................. 2021.2.0-1877-176bdf51370-releases/2021/2
            Description ....... API
    Parsing input parameters
    [ INFO ] Files were added: 1
    [ INFO ]     input.jpg
    [ INFO ] Loading Inference Engine
    [ INFO ] Device info: 
            MYRIAD
            myriadPlugin version ......... 2.1
            Build ........... 2021.2.0-1877-176bdf51370-releases/2021/2
    [ INFO ] Loading network files:
            face-detection-adas-0001.xml
    [ INFO ] Preparing input blobs
    [ INFO ] Batch size is 1
    [ INFO ] Preparing output blobs
    [ INFO ] Loading model to the device
    [ INFO ] Create infer request
    [ WARNING ] Image is resized from (1440, 1048) to (672, 384)
    [ INFO ] Batch size is 1
    [ INFO ] Start inference
    [ INFO ] Processing output blobs
    [0,1] element, prob = 1    (615,122)-(827,377) batch id : 0 WILL BE PRINTED!
    [1,1] element, prob = 1    (875,378)-(1068,628) batch id : 0 WILL BE PRINTED!
    [2,1] element, prob = 0.0756836    (1227,2)-(1338,139) batch id : 0
       :
       :
    [91,1] element, prob = 0.0356445    (1158,123)-(1199,186) batch id : 0
    [92,1] element, prob = 0.0356445    (273,165)-(317,239) batch id : 0
    [93,1] element, prob = 0.0356445    (294,203)-(344,288) batch id : 0
    [ INFO ] Image out_0.bmp created!
    E: [global] [    337810] [object_detectio] XLink_sem_wait:94     
    XLink_sem_inc(sem) method call failed with an error: -1
    E: [global] [    337810] [object_detectio] XLinkResetRemote:257 can't wait dispatcherClosedSem
    
    [ INFO ] Execution successful
    
    [ INFO ] This sample is an API example, for any performance measurements please use the dedicated benchmark_app tool
  9. Raspbian* OS 用の OpenVINO™ ツールキットのインストール完了。

事前トレーニング済みのモデル

インテル®が公開しているトレーニング済みモデル(※2020/12/18現在)
以下のリンク先の下の /FP16 にあるファイル「XXXXXX.bin」「XXXXXX.xml」を前節4. 以降の手順で利用することができる。

https://download.01.org/opencv/2021/openvinotoolkit/2021.2/open_model_zoo/models_bin/3/

FILE NAMEFILE SIZEDATE
Parent directory/--
action-recognition-0001-2020-Dec-10 16:54
age-gender-recognition-retail-0013-2020-Dec-10 16:54
asl-recognition-0004-2020-Dec-10 16:54
bert-large-uncased-whole-word-masking-squad-0001-2020-Dec-10 16:54
bert-large-uncased-whole-word-masking-squad-emb..>-2020-Dec-10 16:54
bert-large-uncased-whole-word-masking-squad-int..>-2020-Dec-10 16:54
bert-small-uncased-whole-word-masking-squad-0001-2020-Dec-10 16:54
bert-small-uncased-whole-word-masking-squad-0002-2020-Dec-10 16:54
bert-small-uncased-whole-word-masking-squad-emb..>-2020-Dec-10 16:54
bert-small-uncased-whole-word-masking-squad-int..>-2020-Dec-10 16:54
driver-action-recognition-adas-0002-2020-Dec-10 16:54
emotions-recognition-retail-0003-2020-Dec-10 16:54
face-detection-0200-2020-Dec-10 16:54
face-detection-0202-2020-Dec-10 16:54
face-detection-0204-2020-Dec-10 16:54
face-detection-0205-2020-Dec-10 16:54
face-detection-0206-2020-Dec-10 16:54
face-detection-adas-0001-2020-Dec-10 16:54
face-detection-retail-0004-2020-Dec-10 16:54
face-detection-retail-0005-2020-Dec-10 16:54
facial-landmarks-35-adas-0002-2020-Dec-10 16:54
faster-rcnn-resnet101-coco-sparse-60-0001-2020-Dec-10 16:54
formula-recognition-medium-scan-0001-2020-Dec-10 16:54
formula-recognition-polynomials-handwritten-0001-2020-Dec-10 16:54
gaze-estimation-adas-0002-2020-Dec-10 16:54
handwritten-japanese-recognition-0001-2020-Dec-10 16:54
handwritten-score-recognition-0003-2020-Dec-10 16:54
handwritten-simplified-chinese-recognition-0001-2020-Dec-10 16:54
head-pose-estimation-adas-0001-2020-Dec-10 16:54
horizontal-text-detection-0001-2020-Dec-10 16:54
human-pose-estimation-0001-2020-Dec-10 16:54
human-pose-estimation-0002-2020-Dec-10 16:54
human-pose-estimation-0003-2020-Dec-10 16:54
human-pose-estimation-0004-2020-Dec-10 16:54
icnet-camvid-ava-0001-2020-Dec-10 16:54
icnet-camvid-ava-sparse-30-0001-2020-Dec-10 16:54
icnet-camvid-ava-sparse-60-0001-2020-Dec-10 16:54
image-retrieval-0001-2020-Dec-10 16:54
instance-segmentation-security-0010-2020-Dec-10 16:54
instance-segmentation-security-0050-2020-Dec-10 16:54
instance-segmentation-security-0083-2020-Dec-10 16:54
instance-segmentation-security-1025-2020-Dec-10 16:54
landmarks-regression-retail-0009-2020-Dec-10 16:54
license-plate-recognition-barrier-0001-2020-Dec-10 16:54
machine-translation-nar-en-ru-0001-2020-Dec-10 16:54
machine-translation-nar-ru-en-0001-2020-Dec-10 16:54
pedestrian-and-vehicle-detector-adas-0001-2020-Dec-10 16:54
pedestrian-detection-adas-0002-2020-Dec-10 16:54
person-attributes-recognition-crossroad-0230-2020-Dec-10 16:54
person-attributes-recognition-crossroad-0234-2020-Dec-10 16:54
person-attributes-recognition-crossroad-0238-2020-Dec-10 16:54
person-detection-0106-2020-Dec-10 16:54
person-detection-0200-2020-Dec-10 16:54
person-detection-0201-2020-Dec-10 16:54
person-detection-0202-2020-Dec-10 16:54
person-detection-0203-2020-Dec-10 16:54
person-detection-action-recognition-0005-2020-Dec-10 16:54
person-detection-action-recognition-0006-2020-Dec-10 16:54
person-detection-action-recognition-teacher-0002-2020-Dec-10 16:54
person-detection-asl-0001-2020-Dec-10 16:54
person-detection-raisinghand-recognition-0001-2020-Dec-10 16:54
person-detection-retail-0002-2020-Dec-10 16:54
person-detection-retail-0013-2020-Dec-10 16:54
person-reidentification-retail-0277-2020-Dec-10 16:54
person-reidentification-retail-0286-2020-Dec-10 16:54
person-reidentification-retail-0287-2020-Dec-10 16:54
person-reidentification-retail-0288-2020-Dec-10 16:54
person-vehicle-bike-detection-2000-2020-Dec-10 16:54
person-vehicle-bike-detection-2001-2020-Dec-10 16:54
person-vehicle-bike-detection-2002-2020-Dec-10 16:54
person-vehicle-bike-detection-crossroad-0078-2020-Dec-10 16:54
person-vehicle-bike-detection-crossroad-1016-2020-Dec-10 16:54
person-vehicle-bike-detection-crossroad-yolov3-..>-2020-Dec-10 16:54
product-detection-0001-2020-Dec-10 16:54
resnet18-xnor-binary-onnx-0001-2020-Dec-10 16:54
resnet50-binary-0001-2020-Dec-10 16:54
road-segmentation-adas-0001-2020-Dec-10 16:54
semantic-segmentation-adas-0001-2020-Dec-10 16:54
single-image-super-resolution-1032-2020-Dec-10 16:54
single-image-super-resolution-1033-2020-Dec-10 16:54
text-detection-0003-2020-Dec-10 16:54
text-detection-0004-2020-Dec-10 16:54
text-image-super-resolution-0001-2020-Dec-10 16:54
text-recognition-0012-2020-Dec-10 16:54
text-spotting-0003-2020-Dec-10 16:54
unet-camvid-onnx-0001-2020-Dec-10 16:54
vehicle-attributes-recognition-barrier-0039-2020-Dec-10 16:54
vehicle-attributes-recognition-barrier-0042-2020-Dec-10 16:54
vehicle-detection-0200-2020-Dec-10 16:54
vehicle-detection-0201-2020-Dec-10 16:54
vehicle-detection-0202-2020-Dec-10 16:54
vehicle-detection-adas-0002-2020-Dec-10 16:54
vehicle-license-plate-detection-barrier-0106-2020-Dec-10 16:54
weld-porosity-detection-0001-2020-Dec-10 16:54
yolo-v2-ava-0001-2020-Dec-10 16:54
yolo-v2-ava-sparse-35-0001-2020-Dec-10 16:54
yolo-v2-ava-sparse-70-0001-2020-Dec-10 16:54
yolo-v2-tiny-ava-0001-2020-Dec-10 16:54
yolo-v2-tiny-ava-sparse-30-0001-2020-Dec-10 16:54
yolo-v2-tiny-ava-sparse-60-0001-2020-Dec-10 16:54
yolo-v2-tiny-vehicle-detection-0001-2020-Dec-10 16:54
LICENSE11.1 KiB2020-Dec-10 16:54
 

参考資料


Last-modified: 2021-04-15 (木) 05:53:12