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来试的。

  • 5
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
FPGA是一种可编程逻辑器件,可以用于加速计算任务。在OpenVINO中,也提供了对FPGA的支持。要在OpenVINO中使用FPGA加速,需要进行以下步骤: 1. 首先,在makefile中添加FPGA相关的头文件和库文件路径。在makefile中,可以使用以下语法来添加OpenVINO的头文件和库文件路径: ``` include_paths := $(openvino_root)/runtime/include library_paths := $(openvino_root)/runtime/lib/intel64 ``` 其中,`openvino_root`是OpenVINO的安装路径。 2. 接下来,需要在makefile中定义链接OpenVINO和FPGA相关的库文件。可以使用以下语法来定义链接库文件: ``` link_openvino := openvino link_librarys := $(link_openvino) ``` 3. 安装OpenVINO工具套件。可以从Intel官方网站下载OpenVINO工具套件,并按照安装说明进行安装。下载地址为:\[https://www.intel.com/content/www/us/en/developer/tools/openvino-toolkit/download.html\](https://www.intel.com/content/www/us/en/developer/tools/openvino-toolkit/download.html),安装说明可以在这里找到:\[https://docs.openvino.ai/nightly/openvino_docs_install_guides_install_dev_tools.html\](https://docs.openvino.ai/nightly/openvino_docs_install_guides_install_dev_tools.html) 4. 在终端中启动OpenVINO笔记本。如果是全新开启的终端,可以使用以下命令来启动OpenVINO笔记本: ``` source $HOME/openvino_env/bin/activate jupyter-lab $HOME/openvino_notebooks/notebooks ``` 其中,`$HOME/openvino_env`是OpenVINO的环境路径,`$HOME/openvino_notebooks/notebooks`是OpenVINO笔记本的路径。\[2\] 通过以上步骤,您就可以在OpenVINO中使用FPGA进行加速了。请注意,具体的操作步骤可能会因为OpenVINO版本的不同而有所差异,建议您参考OpenVINO的官方文档或者安装说明进行操作。\[1\] \[2\] \[3\] #### 引用[.reference_title] - *1* [openvino入门--c++部署的图像分类为例](https://blog.csdn.net/qq_42178122/article/details/125207550)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [【Openvino03】深入了解OpenVINO™ 工具包与Jupyter Notebooks工程](https://blog.csdn.net/Alex_81D/article/details/131432949)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [OpenVINO工具套件使用教程](https://blog.csdn.net/m0_46520099/article/details/125843644)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值