私的AI研究会 > OpenVINO Tips
OpenVINO™ ツールキットのバージョンに合った学習済みモデルをダウンロードする。
インストール・バージョンは 2021.2
vi model_check.py # -*- coding: utf-8 -*- ##-------------------------------------------- ## OpenVINO™ ## Model Check Program ## 2021.02.10 Masahiro Izutsu ##-------------------------------------------- ## python3 model_check.py <model pass> ##-------------------------------------------- import sys import cv2 import numpy as np def main(): # モジュール読み込み from openvino.inference_engine import IECore # Inference Engineコアオブジェクトの生成 ie = IECore() # IRモデルファイルの読み込み net = ie.read_network(model=model+'.xml', weights=model+'.bin') # 入出力blobの名前の取得、入力blobのシェイプの取得 input_key = list(net.input_info.keys())[0] # 入力データ・キー名 input_blob_name = net.input_info[input_key].name output_blob_name = next(iter(net.outputs)) batch,channel,height,width = net.input_info[input_blob_name].input_data.shape exec_net = ie.load_network(network=net, device_name='MYRIAD', num_requests=1) print("input blob: name='{}', N={}, C={}, H={}, W={}".format(input_blob_name, batch, channel, height, width)) if __name__ == '__main__': # 学習済みモデル名 args = sys.argv if 2 <= len(args): model = args[1] else: model = './public/mobilenet-ssd/FP16/mobilenet-ssd' print("model = '{}'".format(model)) main()
pi@raspberrypi:~/workspace $ python3 model_check.py model = './public/mobilenet-ssd/FP16/mobilenet-ssd' input blob: name='data', N=1, C=3, H=300, W=300 pi@raspberrypi:~/workspace $ python3 model_check.py FP16/landmarks-regression-retail-0009 model = 'FP16/landmarks-regression-retail-0009' input blob: name='0', N=1, C=3, H=48, W=48 pi@raspberrypi:~/workspace $ python3 model_check.py ./FP16/face-detection-adas-0001 model = './FP16/face-detection-adas-0001' input blob: name='data', N=1, C=3, H=384, W=672 pi@raspberrypi:~/workspace $ python3 model_check.py public/squeezenet1.1/FP16/squeezenet1.1 model = 'public/squeezenet1.1/FP16/squeezenet1.1' input blob: name='data', N=1, C=3, H=227, W=227
※ ドキュメントの入力 Name は違っている場合が多いので確認しておく。
システムイメージ → <<raspi_ncappzoo_2021_0225_001c.img>>
$ python3 Python 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> print(cv2.getBuildInformation())
General configuration for OpenCV 4.5.1-openvino ===================================== Version control: 705e7b207c4c95231fb18c7ddfad353795aa6531 Platform: Timestamp: 2020-12-01T12:29:06Z Host: Linux 4.15.0-29-generic x86_64 Target: Linux 1 armv7l CMake: 3.7.2 CMake generator: Ninja CMake build tool: /usr/bin/ninja Configuration: Release CPU/HW features: Baseline: NEON required: NEON disabled: VFPV3 C/C++: Built as dynamic libs?: YES C++ standard: 11 C++ Compiler: /usr/bin/arm-linux-gnueabihf-g++ (ver 6.3.0) C++ flags (Release): -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-psabi -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -mfpu=neon -fvisibility=hidden -fvisibility-inlines-hidden -fstack-protector-strong -fPIC -O2 -DNDEBUG -DNDEBUG -D_FORTIFY_SOURCE=2 C++ flags (Debug): -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-psabi -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -mfpu=neon -fvisibility=hidden -fvisibility-inlines-hidden -fstack-protector-strong -fPIC -g -O0 -DDEBUG -D_DEBUG C Compiler: /usr/bin/arm-linux-gnueabihf-gcc C flags (Release): -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-psabi -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -mfpu=neon -fvisibility=hidden -fstack-protector-strong -fPIC -O2 -DNDEBUG -DNDEBUG -D_FORTIFY_SOURCE=2 C flags (Debug): -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-psabi -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -mfpu=neon -fvisibility=hidden -fstack-protector-strong -fPIC -g -O0 -DDEBUG -D_DEBUG Linker flags (Release): -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,--as-needed -z noexecstack -z relro -z now Linker flags (Debug): -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,--as-needed -z noexecstack -z relro -z now ccache: YES Precompiled headers: NO Extra dependencies: dl m pthread rt 3rdparty dependencies: OpenCV modules: To be built: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo python3 stitching ts video videoio Disabled: world Disabled by dependency: - Unavailable: java js python2 Applications: tests perf_tests apps Documentation: NO Non-free algorithms: NO GUI: GTK+: YES (ver 3.22.11) GThread : YES (ver 2.50.3) GtkGlExt: NO Media I/O: ZLib: build (ver 1.2.11) JPEG: build-libjpeg-turbo (ver 2.0.6-62) PNG: build (ver 1.6.37) HDR: YES SUNRASTER: YES PXM: YES PFM: YES Video I/O: FFMPEG: YES avcodec: YES (57.64.101) avformat: YES (57.56.101) avutil: YES (55.34.101) swscale: YES (4.2.100) avresample: NO GStreamer: YES (1.10.4) v4l/v4l2: YES (linux/videodev2.h) Parallel framework: pthreads Trace: YES (with Intel ITT) Other third-party libraries: Inference Engine: YES (2021020000 / 2.1.0) * libs: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/debian9arm/ie/inference_engine/lib/armv7l/libinference_engine.so * includes: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/debian9arm/ie/inference_engine/include nGraph: YES (0.0.0+d2e3e1f) * libs: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/debian9arm/ie/ngraph/lib/libngraph.so * includes: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/debian9arm/ie/ngraph/include Custom HAL: YES (carotene (ver 0.0.1)) Protobuf: build (3.5.1) Python 3: Interpreter: /usr/bin/python3 (ver 3.5.3) Libraries: numpy: /usr/lib/python3.5/dist-packages/numpy/core/include (ver undefined - cannot be probed because of the cross-compilation) install path: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/debian9arm/build_release/install/python/python3 Python (for build): /usr/bin/python2.7 Install to: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/debian9arm/build_release/install -----------------------------------------------------------------
$ python3 Python 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> print(cv2.getBuildInformation())
General configuration for OpenCV 4.5.1-openvino ===================================== Version control: 705e7b207c4c95231fb18c7ddfad353795aa6531 Platform: Timestamp: 2020-12-01T12:30:45Z Host: Linux 4.15.0-29-generic x86_64 CMake: 3.14.5 CMake generator: Ninja CMake build tool: /opt/miniconda/envs/build/bin/ninja Configuration: Release CPU/HW features: Baseline: SSE SSE2 SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 requested: SSE4_2 Dispatched code generation: FP16 AVX AVX2 AVX512_SKX requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX FP16 (1 files): + FP16 AVX AVX (5 files): + AVX AVX2 (31 files): + FP16 FMA3 AVX AVX2 AVX512_SKX (7 files): + FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX C/C++: Built as dynamic libs?: YES C++ standard: 11 C++ Compiler: /usr/bin/c++ (ver 9.3.0) C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -fvisibility=hidden -fvisibility-inlines-hidden -fstack-protector-strong -fPIC -O2 -DNDEBUG -DNDEBUG -D_FORTIFY_SOURCE=2 C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -fvisibility=hidden -fvisibility-inlines-hidden -fstack-protector-strong -fPIC -g -O0 -DDEBUG -D_DEBUG C Compiler: /usr/bin/cc C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -fvisibility=hidden -fstack-protector-strong -fPIC -O2 -DNDEBUG -DNDEBUG -D_FORTIFY_SOURCE=2 C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -fvisibility=hidden -fstack-protector-strong -fPIC -g -O0 -DDEBUG -D_DEBUG Linker flags (Release): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed -z noexecstack -z relro -z now Linker flags (Debug): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed -z noexecstack -z relro -z now ccache: YES Precompiled headers: NO Extra dependencies: dl m pthread rt 3rdparty dependencies: OpenCV modules: To be built: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo python3 stitching ts video videoio Disabled: world Disabled by dependency: - Unavailable: java js python2 Applications: tests perf_tests apps Documentation: NO Non-free algorithms: NO GUI: GTK+: YES (ver 3.24.20) GThread : YES (ver 2.64.3) GtkGlExt: NO Media I/O: ZLib: build (ver 1.2.11) JPEG: build-libjpeg-turbo (ver 2.0.6-62) PNG: build (ver 1.6.37) HDR: YES SUNRASTER: YES PXM: YES PFM: YES Video I/O: FFMPEG: YES avcodec: YES (58.54.100) avformat: YES (58.29.100) avutil: YES (56.31.100) swscale: YES (5.5.100) avresample: YES (4.0.0) GStreamer: YES (1.16.2) v4l/v4l2: YES (linux/videodev2.h) Intel Media SDK: YES (/mnt/nfs/msdk/lin-18.4.1/lib64/libmfx.so) Parallel framework: TBB (ver 2020.1 interface 11101) Trace: YES (with Intel ITT) Other third-party libraries: Intel IPP: 2020.0.0 Gold [2020.0.0] at: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/ubuntu20/build_release/3rdparty/ippicv/ippicv_lnx/icv Intel IPP IW: sources (2020.0.0) at: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/ubuntu20/build_release/3rdparty/ippicv/ippicv_lnx/iw Inference Engine: YES (2021020000 / 2.1.0) * libs: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/ubuntu20/ie/inference_engine/lib/intel64/libinference_engine.so * includes: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/ubuntu20/ie/inference_engine/include nGraph: YES (0.0.0+d2e3e1f) * libs: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/ubuntu20/ie/ngraph/lib/libngraph.so * includes: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/ubuntu20/ie/ngraph/include Custom HAL: NO Protobuf: build (3.5.1) OpenCL: YES (no extra features) Include path: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/ubuntu20/opencv/3rdparty/include/opencl/1.2 Link libraries: Dynamic load Python 3: Interpreter: /opt/miniconda/envs/py3_env/bin/python (ver 3.4.5) Libraries: /opt/miniconda/envs/py3_env/lib/libpython3.4m.so (ver 3.4.5) numpy: /opt/miniconda/envs/py3_env/lib/python3.4/site-packages/numpy/core/include (ver 1.11.3) install path: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/ubuntu20/build_release/install/python/python3 Python (for build): /usr/bin/python2.7 Install to: /home/jenkins/workspace/OpenCV/OpenVINO/2021.2/build/ubuntu20/build_release/install -----------------------------------------------------------------
/opt/intel/openvino_2021/ │ ├── deployment_tools │ ├── demo │ ├── demo_benchmark_app.sh │ ├── demo_security_barrier_camera.sh │ ├── demo_squeezenet_download_convert_run.sh │ ├── inference_engine │ │ │ ├── samples │ │ ├── c │ │ ├── cpp │ │ ├── python │ │ │ ├── demos (../open_model_zoo/demos) │ │ ├── buld_demos.sh │ │ │ │ │ ├── python_demos │ ├── open_model_zoo │ │ │ ├── demos │ │ ├── buld_demos.sh │ │ │ │ │ ├── python_demos │ │ │
※ ~/openvino_demos_python ディレクトリに python/ フォルダを python_sample/ フォルダとしてコピーして使用することにする。
※ フォルダ内の build_demos.sh を実行することで、~/omz_demos_build (~/inference_engine_demos_build) ディレクトリに実行環境がコピーされる。~/omz_demos_build を使用することにする