工具套件下载地址:
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

1.OpenVINO ™工具套件

OpenVINO工具包(ToolKit)主要包括两个核心组件,模型优化器(Model Optimizer)和推理引擎(Inference Engine)。

  • 模型优化器(Model Optimizer)将给定的模型转化为标准的 Intermediate Representation (IR) ,并对模型优化。
    模型优化器支持的深度学习框架:ONNX、TensorFlow、Caffe、MXNet、Kaldi
  • 推理引擎(Inference Engine)支持硬件指令集层面的深度学习模型加速运行,同时对传统的OpenCV图像处理库也进行了指令集优化,有显著的性能与速度提升。
    支持的硬件设备:CPU、GPU、FPGA、VPU

完整的工作流:

  • model:modeldownloader下载公共模型、open_model_zoo自带的模型或者自行训练
  • prepare_inference: 模型优化器,将模型转化为推理引擎需要的格式文件
  • benchmark: 性能因素与基准测试方法
  • select system: 选择正确的系统和操作硬件
  • decode density: 选择合适硬件的另一个因素是系统可支持多少个摄像头
  • full pipeline: 构建流水线进行测试
  • AI application:构建AI应用

使用实例:

模型优化器:将squeezenet1.1.caffemodel转化为IR格式

…\Intel\openvino_2021\deployment_tools\model_optimizer>

mo_caffe.py --input_model  ..\OV-200-lab-files\02\exercise-1\public\squeezenet1.1\squeezenet1.1.caffemodel  --output_dir ..\OV-200-lab-files\02\exercise-1\public\squeezenet1.1\
推理引擎:查看classification_sample_async.py文件并运行

…\Intel\openvino_2021\inference_engine\samples\python\classification_sample_async\classification_sample_async.py 把该文件复制到目标文件夹
…\OV-200-lab-files\02\exercise-1\public\squeezenet1.1>

python classification_sample_async.py -h
python classification_sample_async.py -i car.png -m squeezenet1.1.xml --labels squeezenet1.1.labels -d CPU
python classification_sample_async.py -i images/car.png -m squeezenet1.1.xml --labels squeezenet1.1.labels -d CPU
python classification_sample_async.py -i boy-computer.png -m squeezenet1.1.xml --labels squeezenet1.1.labels -d CPU
python classification_sample_async.py -i burger1.png -m squeezenet1.1.xml --labels squeezenet1.1.labels -d CPU
将squeezenet1.1.caffemodel替换为resnet-50.caffemodel重复上述两个操作
mo_caffe.py --input_model  ..\OV-200-lab-files\02\exercise-1\public\resnet-50\resnet-50.caffemodel  --output_dir ..\OV-200-lab-files\02\exercise-1\public\resnet-50\
python classification_sample_async.py -i car.png -m resnet-50.xml --labels resnet-50.labels -d CPU
python classification_sample_async.py -i boy-computer.jpg -m resnet-50.xml --labels resnet-50.labels -d CPU
python classification_sample_async.py -i burger.jpg -m resnet-50.xml --labels resnet-50.labels -d CPU

2. 深度学习与模型优化器详解

2.1. 模型优化器使用示例

安装模型优化器的必要组件
..\Intel\openvino_2021\deployment_tools\model_optimizer\install_prerequisites>install_prerequisites.bat

ERROR: Can not perform a ‘–user’ install. User site-packages are not visible in this virtualenv
解决:1) Go to the pyvenv.cfg file in the Virtual environment folder 2) Set the include-system-site-packages to true and save the change 3) Reactivate the virtual environment.

下载onnx/mobilenet文件

下载地址:https://github.com/onnx/models/blob/main/vision/classification/mobilenet/model/mobilenetv2-7.onnx

查看模型的说明文件
..\Intel\openvino_2021.4.752\deployment_tools\open_model_zoo\models\public\mobilenet-v2-pytorch\model.yml

相关信息:
framework: pytorch
conversion_to_onnx_args:
–model-name=mobilenet_v2
–weights=dl_dir/mobilenet_v2-b0353104.pth
–import-module=torchvision.models
–input-shape=1,3,224,224
–output-file=conv_dir/mobilenet-v2.onnx
–input-names=data
–output-names=prob
model_optimizer_args:
–input=data
–mean_values=data[123.675,116.28,103.53]
–scale_values=data[58.624,57.12,57.375]
–reverse_input_channels
–output=prob
–input_model=$conv_dir/mobilenet-v2.onnx

使用模型优化器

(venv) D:\guan\learning\intel\virtual\OV-200-lab-files\03\exercise-1>
D:\guan\learning\intel\virtual\OV-200-lab-files\venv\Lib\site-packages\mo.py --input_model mobilenetv2-7.onnx --mean_values=data[123.675,116.28,103.53] --scale_values=data[58.624,57.12,57.375] --reverse_input_channels --output_dir D:\guan\learning\intel\virtual\OV-200-lab-files\03\exercise-1

使用推理引擎对图片进行分类

python classification_sample_async.py -i images/1.jpeg -m mobilenetv2-7.xml --labels label.labels -d CPU

2.2. 使用模型优化器优化SSD-mobilenet模型

SSD 对图形中的对象进行检测和分类,并行搜索不同大小的对象,尝试对每个对象分类
##下载ssd_mobilenet_v2_coco
(venv) D:\guan\learning\intel\virtual\OV-200-lab-files\03\exercise-2>
python D:\guan\learning\intel\virtual\OV-200-lab-files\03\exercise-2\downloader.py --name ssd_mobilenet_v2_coco --output_dir D:\guan\learning\intel\virtual\OV-200-lab-files\03\exercise-2\

查看模型说明

model_optimizer_args:

  • –reverse_input_channels
  • –input_shape=[1,300,300,3]
  • –input=image_tensor
  • –transformations_config=$mo_dir/extensions/front/tf/ssd_v2_support.json
  • –tensorflow_object_detection_api_pipeline_config=$dl_dir/ssd_mobilenet_v2_coco_2018_03_29/pipeline.config
  • –output=detection_classes,detection_scores,detection_boxes,num_detections
  • –input_model=$dl_dir/ssd_mobilenet_v2_coco_2018_03_29/frozen_inference_graph.pb
使用模型优化器优化模型
..\OV-200-lab-files\venv\Lib\site-packages\mo.py --input_model D:\guan\learning\intel\virtual\OV-200-lab-files\03\exercise-2\public\ssd_mobilenet_v2_coco\ssd_mobilenet_v2_coco_2018_03_29\frozen_inference_graph.pb --reverse_input_channels --input_shape=[1,300,300,3] --input=image_tensor --transformations_config=..\OV-200-lab-files\03\exercise-2\ssd_v2_support.json --tensorflow_object_detection_api_pipeline_config=..\OV-200-lab-files\03\exercise-2\public\ssd_mobilenet_v2_coco\ssd_mobilenet_v2_coco_2018_03_29\pipeline.config --output=detection_classes,detection_scores,detection_boxes,num_detections --model_name ssd_mobilenet --output_dir ..\OV-200-lab-files\03\exercise-2\
使用模型检测对象
`python object_detection.py -m ssd_mobilenet.xml --labels labels.txt -i images/1.jpg`

###该步骤未成功AttributeError: ‘openvino.inference_engine.ie_api.IENetwork’ object has no attribute ‘layers’

3、深入了解:改变batches/change input shape/cut portions

creat batches
..\OV-200-lab-files\venv\Lib\site-packages\mo.py --input_model mobilenetv2-7.onnx --mean_values=data[123.675,116.28,103.53] --scale_values=data[58.624,57.12,57.375] --reverse_input_channels --output_dir ..\OV-200-lab-files\03\exercise-3 --batch 4 --model_name mobilenetv2-7_batch4
change input shape
..\OV-200-lab-files\venv\Lib\site-packages\mo.py --input_model mobilenetv2-7.onnx --mean_values=data[123.675,116.28,103.53] --scale_values=data[58.624,57.12,57.375] --reverse_input_channels --output_dir ..\OV-200-lab-files\03\exercise-3 --input_shape [1,3,100,100] --model_name mobilenetv2-7_shapemin
使用推理引擎
python classification_sample_async.py -i 1.jpeg -m mobilenetv2-7.xml --labels labels.txt -d CPU
python classification_sample_async.py -i 1.jpeg -m mobilenetv2-7_shapemin.xml --labels labels.txt -d CPU
cut portions & change format

3. 推理引擎

API文档:https://docs.openvino.ai/latest/api/ie_python_api/api.html

3.1. 使用api创建

ie = IECore()
net = ie.read_network(model=model_xml, weights=model_bin)
exec_net = ie.load_network(network=net, device_name="CPU")
out=exec_net.infer({input_blob:image})

python hello_classification.py#运行
其他plugin:‘hetero’ ‘multi’

3.2. 获取系统中的可用设备及性能数据

devices=ie.available_devices
performance_counters = exec_net.requests[0].get_perf_counts()

4. 性能评估与硬件选型

4.1. 性能参数:

吞吐量及延迟、效率、神经网络的参数、目标设备、模型精度

4.2. 目标追踪实验:添加时间

time_start = time.time()
exec_net.start_async(request_id=next_request_id, inputs=feed_dict)
time_end=time.time()
inference_time=time_end-time_start
sys.stdout.write('%.5s'% inference_time)

4.3. 性能评估实践:benchmark使用

异步运行

python benchmark_app.py -i images/ -m models/resnet-50.xml

python benchmark_app.py -i images/ -m models/ssd-mobilenet.xml

同步运行

python benchmark_app.py -i images/ -m models/ssd-mobilenet.xml --api sync

5 视频处理

5.1 运行多路视频的路人追踪示例

三个视频
python multi_camera_multi_person_tracking.py --m_detector models/person-detection-retail-0013.xml --m_reid models/person-reidentification-retail-0300.xml --config config.py -i Videos/video1.avi Videos/video2.avi Videos/video3.avi --no_show --output out.avi
一个视频
python multi_camera_multi_person_tracking.py --m_detector models/person-detection-retail-0013.xml --m_reid models/person-reidentification-retail-0300.xml --config config.py -i Videos/video1.avi  --output out.avi

6. 完整AI应用流程

了解需求后,选择正确的系统和操作硬件
工作流(视频处理流水线):解码、前处理、推理、后处理、编码
用DL-Streamer创建完整的视频处理流程

OpenVINO工具套件使用教程相关推荐

  1. TF/pytorch/caffe-CV/NLP/音频-全生态CPU部署实战演示-英特尔openVINO工具套件课程总结(下)

    TF-pytorch-caffe~CV/NLP/音频-全生态CPU部署实战演示-英特尔openVINO工具套件课程总结(下) 在上中两篇中我们充分理解了openvino的基本原理以及其硬件基础,在这篇 ...

  2. OpenVINO工具套件高级课程第一课:如何充分使用OpenVINO工具套件?

    一.Traditional Computer Vision & Tools & Libraries 目前,许多平台和操作系统都支持OpenVINO的运行,并将继续扩大支持范围,支持即将 ...

  3. 英特尔OpenVINO工具套件高级课程实验操作记录与学习总结

    英特尔OpenVINO工具套件高级课程&实验操作记录与学习总结 实验机器环境部分信息: dc2-user@10-0-255-63:~$ lsb_release -a No LSB module ...

  4. PaddleX 结合 OpenVINO 工具套件 ,优化深度学习算法CPU部署性能

    引言 当今世界,深度学习技术正得以广泛应用,为工业质检.安防巡检.金融.医疗.能源等各行各业降本增效.然而,深度学习算法往往需要较高性能的计算芯片作为支撑,以满足大计算量.高推理速度等产业需求,这为众 ...

  5. 解读至强的小秘密之 OpenVINO 工具套件,面向 AI 任务的 “神奇改造车间”

    经历了之前几期对至强平台的揭秘,我们想必都已了解:英特尔® 至强® 平台对于 AI 应用的加速,从来都不是依靠某个单一的产品或技术特性来实现的.我们看到英特尔® AVX-512 和英特尔® 深度学习加 ...

  6. 英特尔OpenVINO工具套件快速构建一款AI应用之课程体验

    首先和大家说明一下,这是一个体验课程笔记 本文记录.博主学习该课程前两个章节内容的笔记心得 声明:本文禁止转载.感谢理解与支持 文末有课程链接 这个课程.博主会一边学习.一边撰写更多笔记类教程 对 模 ...

  7. 学习笔记(01):英特尔® OpenVINO™工具套件初级课程-如何加速视频处理进程?

    立即学习:https://edu.csdn.net/course/play/27685/385715?utm_source=blogtoedu 1Frame = 1920*1080 pxels RGB ...

  8. 学习笔记(13):英特尔®OpenVINO™工具套件中级课程-推理引擎详解内部API

    立即学习:https://edu.csdn.net/course/play/28807/427188?utm_source=blogtoedu 目录 1.推理引擎详解 2.推理引擎API (ie_ap ...

  9. 基于OpenVINO工具套件简单实现YOLOv7预训练模型的部署_附带预训练模型

    ●一.YOLOv7简介● 查看全文 http://www.taodudu.cc/news/show-7092220.html 相关文章: 轻量型目标检测算法总结 中交路桥科技浅谈:边坡稳定的影响因素及 ...

最新文章

  1. 加油站会员管理系统源码php_分享一下:关于一对一直播源码的重要组成部分
  2. 济南职业学院计算机信息管理在哪个校区,计算机学院圆满完成省计算机信息管理专业教学指导方案开发...
  3. 机器学习第九篇:详解Adaboost算法
  4. 使用jclouds库在Amazon S3上上传
  5. Node 中的开发环境与生产环境 和 使用Morgan打印请求信息
  6. 一个神奇的bug:OOM?优雅终止线程?系统内存占用较高?
  7. android 初学者实现 popupwindow的自动弹出,Android popupWindow弹出窗体实现方法分析
  8. DateTime字段控件值显示短格式的做法
  9. 建模步骤_UG1847建模机械零件,零基础可读详细图文步骤
  10. 九度 题目1183:守形数----------------我用的方法自创
  11. 中国工业管理软件如何突围?
  12. NOD 32 企业版远程管理服务器病毒库更新失败
  13. Java物联网中间件_物联网中间件技术——Niagara介绍.pdf
  14. 华为云GaussDB技术创新持续发力,荣膺DTCC2021创新大奖
  15. CodeForces - 1299B. Aerodynamic
  16. 「镁客·请讲」移康智能朱鹏程:做产品就要直击痛点,多余的功能只会是噱头...
  17. JavaWEB(AJAX实现分页)
  18. 20220313_朴素贝叶斯
  19. Ubuntu 16.04 4k屏高分辨率卡顿问题
  20. 浪潮 服务器 修改raid,浪潮服务器RAID配置方法-20210723233916.docx-原创力文档

热门文章

  1. 北航离散数学期末总结
  2. python copy函数用法_copy.copy()函数用法
  3. 揭秘『边缘计算』“搅局”沪深股市的背后
  4. comint32.sys,GD*I32.dll,bj*rl.dll,addr*help.dll木马群的删除
  5. windows电脑与苹果手机、ipad实现文件共享
  6. html+css+js:坚持30s小游戏
  7. vue+element-ui创建调查问卷
  8. Python+Selenium之定位新打开的标签(窗口)
  9. 儿童手机与成人手机的区别
  10. 【自撰】zooKeeper 集成 Java代码