OpenVINO+Win10安装及环境配置攻略
OpenVINO主要包括模型优化器(Model Optimizer)和推理引擎(Inference engine)两部分。模型优化器负责将各种格式的深度神经网络模型转换成统一的自定义格式,并在转换过程中进行模型优化;推理引擎接受经过模型优化器转换并优化的网络模型,为Intel的各种计算设备提供高性能的神经网络推理运算。本文主要记录在Win10 X64+VS2019+Python3.6环境下的安装过程,以及安装过程中的注意事项。下图是其推理引擎的验证结果:
参考链接&致谢
在Python+OpenCV中调用本文中提及的车牌检测模型:OpenCV调用OpenVINO模型vehicle-license-plate-detection-barrier检测车牌
1. Install Intel® Distribution of OpenVINO™ toolkit for Windows* 10
Install Intel® Distribution of OpenVINO™ toolkit for Windows* 10是官方给出的安装教程,从中我们可以知道OpenVINO的依赖条件:
CMake3.10或更高版本+X64,若是VS2019,则需要CMake3.14(含)及以上版本。
注:CMake必须是安装版本(.msi)且安装过程中选择设置环境变量;CMake的ZIP的压缩档即便是已设置环境变量,OpenVINO的安装程序也无法检测到,仍然会认为CMake缺失。
2. OpenVINO下载与安装
OpenVINO下载链接OpenVINO Toolkit,下载之前,我们需要根据自己的需求进行一些选择,界面如下图所示:
3. OpenVINO设置环境变量
OpenVINO设置环境变量有两种方法:一种是每次使用时都用命令提示符设置一次;另一种手动永久设置环境变量。
单次设置环境变量
打开command.exe,切换至OpenVINO安装目录下的setupvars.bat文件所在路径,运行setupvars.bat,运行结果如下:
1 2 3 |
C:\Program Files (x86)\Intel\openvino_2021.1.110\bin>setupvars.bat Python 3.6.5 [setupvars.bat] OpenVINO environment initialized |
运行完成后,在同一个command.exe窗口下检查opencv的版本。只有在如下输出结果时,才可以在opencv中调用openvino的相关示例或模型。
注:检查opencv的版本需要在运行setupvars.bat命令之后,且在同一个command.exe窗口中。若另外打开一个command.exe或者将setupvars.bat的运行窗口关闭,则OpenVINO的环境变量设置均处于失效状态。
1 2 3 4 5 6 |
C:\Program Files (x86)\Intel\openvino_2021.1.110\bin>python Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> print(cv2.__version__) 4.5.0-openvino |
永久设置环境变量
为 Windows 永久设置 OpenVINO™环境变量®10
4. Configure the Model Optimizer
1 |
cd C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\model_optimizer\install_prerequisites |
1 |
install_prerequisites.bat |
5.运行OpenVINO验证脚本
1 |
C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo |
1 |
demo_squeezenet_download_convert_run.bat |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
Image C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo\car.png classid probability label ------- ----------- ----- 817 0.6853030 sports car, sport car 479 0.1835197 car wheel 511 0.0917197 convertible 436 0.0200694 beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon 751 0.0069604 racer, race car, racing car 656 0.0044177 minivan 717 0.0024739 pickup, pickup truck 581 0.0017788 grille, radiator grille 468 0.0013083 cab, hack, taxi, taxicab 661 0.0007443 Model T [ INFO ] Execution successful [ INFO ] This sample is an API example, for any performance measurements please use the dedicated benchmark_app tool ###############|| Classification demo completed successfully ||############### |
1 |
demo_security_barrier_camera.bat |
该脚本下载了三个经过预先训练的模型IR,构建了Security Barrier Camera Demo 应用程序,并与下载的模型和demo目录中的car_1.bmp 图像一起运行它,以显示推理管道。验证脚本使用车辆识别,其中车辆属性彼此建立,以缩小特定属性的范围。首先,将物体识别为车辆。该标识用作下一个模型的输入,该模型标识特定的车辆属性,包括车牌。最后,将识别为车牌的属性用作第三种模型的输入,该模型可以识别车牌中的特定字符。图像检测结果以及相应显示图像如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[ INFO ] InferenceEngine: API version ......... 2.1 Build ........... 2021.1.0-1237-bece22ac675-releases/2021/1 [ INFO ] Files were added: 1 [ INFO ] C:\Program Files (x86)\Intel\openvino_2021.1.110\deployment_tools\demo\car_1.bmp [ INFO ] Loading device CPU CPU MKLDNNPlugin version ......... 2.1 Build ........... 2021.1.0-1237-bece22ac675-releases/2021/1 [ INFO ] Loading detection model to the CPU plugin [ INFO ] Loading Vehicle Attribs model to the CPU plugin [ INFO ] Loading Licence Plate Recognition (LPR) model to the CPU plugin [ INFO ] Number of InferRequests: 1 (detection), 3 (classification), 3 (recognition) [ INFO ] 4 streams for CPU [ INFO ] Display resolution: 1920x1080 [ INFO ] Number of allocated frames: 3 [ INFO ] Resizable input with support of ROI crop and auto resize is disabled |
本文到此结束,感谢支持,欢迎关注。