OpenVINO入门笔记

一、简介

官方原文:https://software.intel.com/zh-cn/openvino-toolkit/

使用英特尔®分布式OpenVINO™工具包开发模拟人类视觉的应用程序和解决方案。该工具包基于卷积神经网络(CNN),可扩展英特尔®硬件(包括加速器)的工作负载,并最大限度地提高性能。

  • 在边缘启用基于CNN的深度学习推理
  • 支持跨计算机视觉加速器的异构执行 - CPU,GPU,英特尔®Movidius™神经计算棒和FPGA - 使用通用API
  • 通过功能库和预优化内核加快产品上市速度
  • 包括针对计算机视觉标准的优化调用,包括OpenCV *,OpenCL™和OpenVX *
    在这里插入图片描述

OpenVINO™工具包是一个开源产品。它包含用于英特尔®处理器(用于CPU),英特尔®处理器显卡(用于GPU)和异构支持的深度学习部署工具包(DLDT)。它包括一个带有预训练模型,样本和演示的开放模型库。

  • OpenVINO™工具包:https://01.org/openvinotoolkit

二、开始(基于Ubuntu 16.04LTS,64位)

官方原文:https://docs.openvinotoolkit.org/latest/_docs_install_guides_installing_openvino_linux.html#introduction
我的电脑系统:

下载(Linux):https://software.intel.com/en-us/openvino-toolkit/choose-download/free-download-linux
解压并进入目录:

$ tar -xvzf l_openvino_toolkit_p_<version>.tgz
$ cd l_openvino_toolkit_p_2019.1.144/
# 如果您安装了以前版本的Intel Distribution of OpenVINO工具包,请重命名或删除这两个目录:
# /home/<user>/inference_engine_samples
# /home/<user>/openvino_models
$ sudo ./install_GUI.sh
# 安装很简单,一直下一步就行。

1.安装外部软件依赖项

这些依赖关系是必需的:

  • 英特尔优化的OpenCV
  • 深度学习推理引擎
  • 深度学习模型优化工具
# 切换到install_dependencies目录:
$ cd /opt/intel/openvino/install_dependencies/
# 运行脚本以下载并安装外部软件依赖项:
$ sudo -E ./install_openvino_dependencies.sh

2.设置环境变量

# 在编译和运行OpenVINO™应用程序之前,必须更新多个环境变量。运行以下脚本以临时设置环境变量:
$ source /opt/intel/openvino/bin/setupvars.sh
# 通过以下方式来永久生效:
$ gedit ~/.bashrc
# 在文件最后一行添加:
source /opt/intel/openvino/bin/setupvars.sh
# 保存并关闭文件

3.配置模型优化工具

Model Optimizer是一个基于Python *的命令行工具,用于从流行的深度学习框架(如Caffe *,TensorFlow *,Apache MXNet *,ONNX *和Kaldi *)导入经过训练的模型。

Model Optimizer是OpenLinkO工具包的Intel Distribution的关键组件。如果不通过模型优化器运行模型,则无法对训练的模型进行推理。当您通过模型优化器运行预先训练的模型时,您的输出是网络的中间表示(IR)。Intermediate Representation是一对描述整个模型的文件:

  • .xml:描述网络拓扑
  • .bin:包含权重和偏差二进制数据

有关模型优化程序的更多信息,请参阅模型优化程序开发人员指南:https://docs.openvinotoolkit.org/latest/_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html

同时配置所有支持的框架
$ cd /opt/intel/openvino/deployment_tools/model_optimizer/install_prerequisites
$ sudo ./install_prerequisites.sh
[WARNING] All Model Optimizer dependencies are installed globally.
[WARNING] If you want to keep Model Optimizer in separate sandbox
[WARNING] run install_prerequisites.sh venv {caffe|tf|mxnet|kaldi|onnx}

也可以单独配置每个框架

#For Caffe:
#sudo ./install_prerequisites_caffe.sh
#For TensorFlow:
#sudo ./install_prerequisites_tf.sh
#For MXNet:
#sudo ./install_prerequisites_mxnet.sh
#For ONNX:
#sudo ./install_prerequisites_onnx.sh
#For Kaldi:
#sudo ./install_prerequisites_kaldi.sh

4.运行验证脚本以验证安装

$ cd /opt/intel/openvino/deployment_tools/demo

# 运行图像分类验证脚本:
$ sudo ./demo_squeezenet_download_convert_run.sh
# 遇到一些问题:
[ ERROR ]  
Detected not satisfied dependencies:
	protobuf: installed: 3.7.1, required: 3.6.1
	test-generator: not installed, required: 0.1.1
	defusedxml: not installed, required: 0.5.0
# 解决:
$ cd /opt/intel/openvino_2019.1.144/deployment_tools/model_optimizer/install_prerequisites/
$ sudo ./install_prerequisites_caffe.sh

# 运行 Inference Pipeline 验证脚本:
$ sudo ./demo_security_barrier_camera.sh

5.英特尔®处理器显卡(GPU)的步骤

$ cd /opt/intel/openvino/install_dependencies/
$ sudo -E su
# 安装使用GPU插件所需的OpenCL™驱动程序组件的英特尔®图形计算运行时,并为英特尔®集成显卡编写自定义图层:
$ ./install_NEO_OCL_driver.sh
# 有以下输出,我暂时没管它,至少是成功了。
Installation completed successfully.
Next steps:
Add OpenCL users to the video group: 'sudo usermod -a -G video USERNAME'
   e.g. if the user running OpenCL host applications is foo, run: sudo usermod -a -G video foo
   Current user has been already added to the video group

If you use 8th Generation Intel® Core™ processor, you will need to add:
   i915.alpha_support=1
   to the 4.14 kernel command line, in order to enable OpenCL functionality for this platform.

6.openVINO卸载

$ cd /opt/intel/openvino/openvino_toolkit_uninstaller/
$ sudo ./uninstall_GUI.sh

7.其他

转换你的Caffe *模型:https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_Caffe.html
转换你的TensorFlow *模型:https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_TensorFlow.html
转换您的MXNet *模型:https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_MxNet.html
转换你的ONNX *模型:https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_ONNX.html

三、Hello World人脸检测教程

GitHub:https://github.com/intel-iot-devkit/inference-tutorials-generic

本教程将从一个基本应用程序开始,该应用程序可以读入图像数据并将图像输出到窗口。从那里开始,每个步骤都会添加深度学习模型,用于处理图像数据并进行推理。在最后一步中,完整的应用程序将能够检测到面部,报告面部的年龄和性别,并绘制表示每个面部的头部姿势的3D轴。

因为我安装的是l_openvino_toolkit_p_2019.1.144版本,所以选择分支版本2019 R1.0

# 源码
$ git clone https://github.com/intel-iot-devkit/inference-tutorials-generic.git
$ cd inference-tutorials-generic
$ git checkout openvino_toolkit_2019_r1_0
# 切换到面部检测教程文件夹:
$ cd face_detection_tutorial
# 下载模型
$ source ./scripts/get_models.sh

我先编译并运行了step1,保证openCV没有问题:

$ cd ~/projects/inference-tutorials-generic/face_detection_tutorial/step_1/cmake-build-debug
$ cmake ..
$ make -j12
$ ./intel64/Debug/face_detection_tutorial
# 注:源文件内需要修改 FLAGS_i 参数,修改为自己的摄像头网络地址。

然后又尝试编译运行step2,但运行起来有问题没能处理:

$ cd ~/projects/inference-tutorials-generic/face_detection_tutorial/step_2/cmake-build-debug
$ cmake ..
$ make -j12
$ ./intel64/Debug/face_detection_tutorial
# 注:源文件内需要修改 FLAGS_i 参数,修改为自己的摄像头网络地址。
#     源文件内需要修改 FLAGS_m 参数,修改为模型文件目录。
#报错:
[ ERROR ] Cannot make shared blob! The blob type cannot be used to store objects of current precision
/opt/intel/openvino_2019.1.144/deployment_tools/inference_engine/include/details/ie_exception_conversion.hpp:71
#思考:可能和依赖的某个程序有关,可能是openCV,在CMake的时候注意openCV的依赖路径。

后来使用的是Github上找的一个openVINO的demo来试的。

发布了26 篇原创文章 · 获赞 13 · 访问量 2万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章