AI sales kit:執行Openvino Object Detection demo及Yolo v3/v4 benchmark展示

執行平台:

  • 平台:Tiger Lake (TGL)
  • 系統:Ubuntu 20.04

執行環境準備:

  • 安裝Docker套件
$sudo apt update
$sudo apt-get remove docker docker-engine docker.io containerd runc
$sudo apt install curl

$curl -fsSL https://get.docker.com -o get-docker.sh
$sudo sh get-docker.sh
  • 新增使用者的Docker執行權限
$sudo usermod -aG docker $USER
  • 確認Docker可正常執行
$docker run hello-world

執行正常應出現如下訊息:

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/

若執行後出現如下錯誤訊息,請先重新啟動Ubuntu後再試一次:

docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

 

執行Openvino的Object Dectection demo:

  • 下載測試影片
$wget -O ~/Downloads/NewVideo2.mp4 https://github.com/incluit/OpenVino-For-SmartCity/raw/master/data/NewVideo2.mp4
  • 下載Docker image
!此處下載的docker image為WPI Engineer所建立,僅作為下載測試使用,請勿push個人變動後的Docker image,若有變動需求,請改為使用個人的Docker ID
$docker pull wpiamanda/openvino:2021.3_developer_models

可使用以下指令確認本地端Docker image:

$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
wpiamanda/openvino 2021.3_developer_models dd16c582173e 4 weeks ago 4.13GB
  • 建立Demo的Script檔案
請將以下內容儲存為smartcity_demo.sh
#!/bin/bash

source /opt/intel/openvino/bin/setupvars.sh
cd
gst-launch-1.0 filesrc location=/mnt/NewVideo2.mp4 ! decodebin ! gvadetect model=/opt/intel/openvino_models/public/yolo-v3-tf/FP16/yolo-v3-tf.xml model-proc=/opt/intel/openvino/data_processing/dl_streamer/samples/model_proc/yolo-v3-tf.json device=GPU ! queue ! gvawatermark ! videoconvert ! fpsdisplaysink video-sink=xvimagesink sync=false
複製smartcity_demo.sh至Downloads資料夾
$cp smartcity_demo.sh ~/Downloads/​
  • 執行Object Detection demo
$docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -v ~/Downloads:/mnt --device /dev/dri:/dev/dri --group-add=$(stat -c "%g" /dev/dri/render*) --rm wpiamanda/openvino:2021.3_developer_models /mnt/smartcity_demo.sh
執行結果
smartcity demo screen

執行Yolo v3/v4 Benchmark:

  • 建立benchmark的執行檔案
請將以下內容儲存為run_command.py
import subprocess

import re

#cmd = 'python3 /opt/intel/openvino/deployment_tools/tools/benchmark_tool/benchmark_app.py -m /mnt/openvino_models/public/yolo-v3-tf/FP16/yolo-v3-tf.xml -d CPU -api async -t 1'

fp = open('benchmark_models_cmds.txt', "r")
for cmd in iter(fp):
print("cmd:{}".format(cmd))
stdoutdata = subprocess.getoutput(cmd)
for item in stdoutdata.split("\n"):
if "Latency" in item:
print(item)
elif "Throughput" in item:
print(item)
elif "Read network" in item:
print(item)
elif "Load network" in item:
print(item)
elif "First inference" in item:
print(item)
elif "DNN" in item:
print(item)
elif "Measuring" in item:
print(item)

fp.close()
複製run_command.py至Downloads資料夾
$cp run_command.py ~/Downloads/​
  • 建立benchmark model的執行命令列表
請將以下內容儲存為benchmark_models_cmds.txt,也可自行修改model
python3 /opt/intel/openvino/deployment_tools/tools/benchmark_tool/benchmark_app.py -m /opt/intel/openvino_models/public/yolo-v3-tf/FP32/yolo-v3-tf.xml -d CPU -api async -t 60
python3 /opt/intel/openvino/deployment_tools/tools/benchmark_tool/benchmark_app.py -m /opt/intel/openvino_models/public/yolo-v3-tf/FP16/yolo-v3-tf.xml -d CPU -api async -t 60
python3 /opt/intel/openvino/deployment_tools/tools/benchmark_tool/benchmark_app.py -m /opt/intel/openvino_models/public/yolo-v3-tf/FP16/yolo-v3-tf.xml -d CPU -api async -t 60
python3 /opt/intel/openvino/deployment_tools/tools/benchmark_tool/benchmark_app.py -m /opt/intel/openvino_models/public/yolo-v3-tf/FP32/yolo-v3-tf.xml -d GPU -api async -t 60
python3 /opt/intel/openvino/deployment_tools/tools/benchmark_tool/benchmark_app.py -m /opt/intel/openvino_models/public/yolo-v3-tf/FP16/yolo-v3-tf.xml -d GPU -api async -t 60
python3 /opt/intel/openvino/deployment_tools/tools/benchmark_tool/benchmark_app.py -m /opt/intel/openvino_models/public/yolo-v3-tf/FP16/yolo-v3-tf.xml -d GPU -api async -t 60
python3 /opt/intel/openvino/deployment_tools/tools/benchmark_tool/benchmark_app.py -m /opt/intel/openvino_models/public/yolo-v4-tf/FP32/yolo-v4-tf.xml -d CPU -api async -t 60
python3 /opt/intel/openvino/deployment_tools/tools/benchmark_tool/benchmark_app.py -m /opt/intel/openvino_models/public/yolo-v4-tf/FP16/yolo-v4-tf.xml -d CPU -api async -t 60
python3 /opt/intel/openvino/deployment_tools/tools/benchmark_tool/benchmark_app.py -m /opt/intel/openvino_models/public/yolo-v4-tf/FP16/yolo-v4-tf.xml -d CPU -api async -t 60
python3 /opt/intel/openvino/deployment_tools/tools/benchmark_tool/benchmark_app.py -m /opt/intel/openvino_models/public/yolo-v4-tf/FP32/yolo-v4-tf.xml -d GPU -api async -t 60
python3 /opt/intel/openvino/deployment_tools/tools/benchmark_tool/benchmark_app.py -m /opt/intel/openvino_models/public/yolo-v4-tf/FP16/yolo-v4-tf.xml -d GPU -api async -t 60
python3 /opt/intel/openvino/deployment_tools/tools/benchmark_tool/benchmark_app.py -m /opt/intel/openvino_models/public/yolo-v4-tf/FP16/yolo-v4-tf.xml -d GPU -api async -t 60
複製benchmark_models_cmds.txt至Downloads資料夾
$cp benchmark_models_cmds.txt ~/Downloads/​
  • 執行Benchmark
執行Docker container
$docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -v ~/Downloads:/mnt --device /dev/dri:/dev/dri --group-add=$(stat -c "%g" /dev/dri/render*) wpiamanda/openvino:2021.3_developer_models

進入Docker container後執行Benchmark驗證

$cd /mnt/
$python3 run_command.py
 執行結果
Benchmark screen

執行完畢,離開Docker container

$exit

★博文内容均由个人提供,与平台无关,如有违法或侵权,请与网站管理员联系。

★文明上网,请理性发言。内容一周内被举报5次,发文人进小黑屋喔~

评论