小小甜菜OpenVINO爬坑记

小小甜菜OpenVINO爬坑记

OpenVINO是intel提供的一个深度学习优化工具,目前可以使用在win10,Ubuntu16.04两个平台上,官方已经宣布后期会支持树莓派系统。它是Movidius x的使用接口,同时支持多种框架,也提供了大量例程。
我使用的是UP Squared板卡,运行Ubuntu16.04。

在ubuntu上安装OpenVINO

//ubuntu启动
ssh [email protected]
vncserver
vncviewer 192.168.0.101
//我安装在ubuntu16.04上
//解压缩l_openvino_toolkit_p_2019.3.334
cd l_openvino_toolkit_p_2019.3.334
sudo ./install_GUI.sh
cd /opt/intel/openvino/install_dependencies
sudo -E ./install_openvino_dependencies.sh
sudo gedit ~/.bashrc
//最后添加:source /opt/intel/openvino/bin/setupvars.sh
source ~/.bashrc
cd /opt/intel/openvino/deployment_tools/model_optimizer/install_prerequisites
sudo ./install_prerequisites.sh
//运行dome
cd /opt/intel/openvino_2019.2.242/deployment_tools/inference_engine/samples
./build_samples.sh
//protobuf-3.6.1-py3.5-nspkg.pth出错解决办法
pip3 install --user protobuf -i https://pypi.tuna.tsinghua.edu.cn/simple
//模型下载
sudo -E pip3 install pyyaml requests -i https://pypi.tuna.tsinghua.edu.cn/simple
cd /opt/intel/openvino_2019.2.242/deployment_tools/tools/model_downloader
sudo ./downloader.py --all
sudo ./downloader.py --name face-detection-retail-0004
//使用Movidius,在新终端下
sudo usermod -a -G users "$(whoami)"
sudo cp /opt/intel/openvino/inference_engine/external/97-myriad-usbboot.rules /etc/udev/rules.d/
cd /etc/udev/rules.d
sudo gedit 97-myriad-usbboot.rules
//修改为0666
SUBSYSTEM=="usb", ATTRS{idProduct}=="2150", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
sudo udevadm control --reload-rules
sudo udevadm trigger
sudo ldconfig
//使用GPU
cd /opt/intel/openvino/install_dependencies
sudo -E su
./install_NEO_OCL_driver.sh
reboot
//在安装openvino后,我的环境出了问题,GPU版yolov3无法运行,我使用了anaconda3
bash Anaconda3-4.3.1-Linux-x86_64.sh
//安装最后一个选no,这样可以每次手动激活
export PATH="/home/xs/anaconda3/bin:$PATH"
//更换国内源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --set show_channel_urls yes

官方说明
参考
树莓派预览版

开源项目

//ubuntu16.04+OpenVINO(R4)+USB摄像头
//该项目默认服务器与处理后台放在一起,和通过修改实现前后端分离。项目使用Node.js,后台使用C++构建mosquitto服务器。
//安装依赖
sudo apt install ffmpeg
sudo apt install libssl-dev
sudo apt install npm nodejs nodejs-dev nodejs-legacy
sudo apt install libzmq3-dev libkrb5-dev
sudo apt install sqlitebrowser
git clone https://github.com/17702513221/openVINO.git
//服务器配置
cd /home/xs/openVINO/AI_work/webservice/server
npm install
cd /home/xs/openVINO/AI_work/webservice/front-end
npm install
npm run dist
//sh文件如运行不了,需设置权限允许作为程序执行文件
//运行程序(crossroad_camera_demo_cpp:人物风格检测)
cd openVINO/AI_work/crossroad_camera_demo_cpp
wget https://github.com/intel-iot-devkit/sample-videos/raw/master/worker-zone-detection.mp4
./build.sh
./start.sh
//运行程序(face_access_control_cpp:面部识别)
cd face_access_control_cpp
./build.sh
./start.sh
//浏览器打开
http://localhost:8080
//运行程序(machine_operator_monitor_cpp:专注力检测)
cd machine_operator_monitor_cpp
wget https://github.com/intel-iot-devkit/sample-videos/raw/master/head-pose-face-detection-female.mp4
./build.sh
./start.sh
//运行程序(parking_lot_counter_cpp:车辆进出统计)
cd parking_lot_counter_cpp
wget https://github.com/intel-iot-devkit/sample-videos/raw/master/car-detection.mp4
./build.sh
./start.sh
//运行程序(pedestrian_tracker_cpp:人员查找,视频分割)
cd pedestrian_tracker_cpp
wget https://github.com/intel-iot-devkit/sample-videos/raw/master/worker-zone-detection.mp4
./build.sh
./start.sh
//运行程序(restricted_zone_notifier_cpp:人体检测)
cd restricted_zone_notifier_cpp
wget https://github.com/intel-iot-devkit/sample-videos/raw/master/worker-zone-detection.mp4
./build.sh
./start.sh
//运行程序(security_barrier_camera_cpp:车牌,车型识别)
cd security_barrier_camera_cpp
./build.sh
./start.sh
//运行程序(yolov3_cpp:yolov3识别)
//先生成模型,默认下载官网权重转,实际项目可以使用darknet训练自己的权重
git clone https://github.com/17702513221/tensorflow_tools.git
cd tensorflow-yolo-v3
wget https://pjreddie.com/media/files/yolov3.weights
wget https://raw.githubusercontent.com/nealvis/media/master/traffic_vid/bus_station_6094_960x540.mp4
python3 demo.py --weights_file yolov3.weights --class_names coco.names --input_img Traffic.jpg --output_img out.jpg
cd /opt/intel/computer_vision_sdk/deployment_tools/model_optimizer
sudo python3 mo_tf.py --input_model /home/xs/xs/tensorflow-yolo-v3/yolo_v3.pb --tensorflow_use_custom_operations_config extensions/front/tf/yolo_v3.json --input_shape=[1,416,416,3]
将生成的yolo_v3.xml和yolo_v3.bin复制到本文件夹下
cd /home/xs/inference_engine_samples/intel64/Release
//视频测试:
./object_detection_demo_yolov3_async -i /home/xs/tensorflow_tools/tensorflow-yolo-v3/bus_station_6094_960x540.mp4 -m /home/xs/tensorflow_tools/tensorflow-yolo-v3/yolo_v3.xml -d CPU
//摄像头测试:
./object_detection_demo_yolov3_async -i cam -m /home/xs/tensorflow_tools/tensorflow-yolo-v3/yolo_v3.xml -d CPU
//下载我的开源项目运行:
git clone https://github.com/17702513221/openVINO.git
cd AI_work/yolov3_cpp
./build.sh
//测试(需先用tensorflow-yolo-v3生成模型,测试默认CPU其它需求自行修改)
./start.sh
//监视发送到本地服务器的MQTT消息,发送的是labels的序号,如:person对应0(需先使用新终端开启本地服务器)
mosquitto_sub -t 'yolov3/results'

摄像头监控

//环境搭建在ubuntu16.04+OpenVINO(R3)
sudo apt update
sudo apt install ffmpeg
git clone https://github.com/17702513221/openVINO.git
//构建程序(测试版)
cd /home/xs/openVINO/reference_example/web_detector/application
source env.sh
mkdir -p build && cd build
cmake ..
make
//构建程序(web显示版)
cd /home/xs/openVINO/reference_example/web_detector/application
source env.sh
mkdir -p build && cd build
cmake ..
make CXX_DEFINES=-DUI_OUTPUT
//运行该应用程序
cd /home/xs/openVINO/reference_example/web_detector/build
//在CPU上运行
./web_detector -d CPU -m ../resources/ssd-cpu.xml -l ../resources/labels.txt
//在神经计算棒上运行
./web_detector -d MYRIAD -m ../resources/ssd-ncs.xml -l ../resources/labels.txt
//在浏览器上显示结果
google-chrome  --user-data-dir=$HOME/.config/google-chrome/Web_detector --new-window --allow-file-access-from-files --allow-file-access --allow-cross-origin-auth-prompt index.html
//查询摄像头设备号
ls /dev/video*
//修改conf.txt测试摄像头或视频
/dev/video0 person
../resources/bus_station_6094_960x540.mp4 person

人员计数器

//安装依赖环境
sudo apt update
sudo apt install npm nodejs nodejs-dev nodejs-legacy
sudo apt install libzmq3-dev libkrb5-dev
sudo apt install libssl-dev
sudo apt-get install doxygen graphviz
git clone https://github.com/17702513221/openVINO.git
cd /home/xs/openVINO/reference_example/paho.mqtt.c
make
make html
sudo make install
sudo ldconfig
cd /home/xs/openVINO/reference_example/people-counter/ieservice
mkdir -p build && cd build
source /opt/intel/computer_vision_sdk/bin/setupvars.sh
cmake ..
make
cd /home/xs/openVINO/reference_example/people-counter/webservice/ui
npm install
cd /home/xs/openVINO/reference_example/people-counter/webservice/server
npm install
sudo apt install ffmpeg
//运行程序
cd /home/xs/openVINO/reference_example/people-counter/webservice/server/node-server
node ./server.js
cd /home/xs/openVINO/reference_example/people-counter/webservice/ui
npm run dev
cd /home/xs/openVINO/reference_example/people-counter
sudo ffserver -f ./ffmpeg/server.conf
cd /home/xs/openVINO/reference_example/people-counter/ieservice/bin/intel64/Release
wget https://raw.githubusercontent.com/nealvis/media/master/traffic_vid/bus_station_6094_960x540.mp4
export MQTT_SERVER=localhost:1884
export MQTT_CLIENT_ID=cvservice
./obj_recognition -i bus_station_6094_960x540.mp4 -m ssd-cpu.xml -l  ssd-cpu.bin -d CPU -t SSD -thresh 0.7 0 2>/dev/null | ffmpeg -v warning -f rawvideo -pixel_format bgr24 -video_size 544x320 -i - http://localhost:8090/fac.ffm
//5.浏览器打开
http://localhost:8080

openVINO使用Intel® System Studio编写教学
System Studio许可证下载

小结

openVINO是一个非常方便部署应用AI模型的平台,其优点在于:
1.丰富的例程,方便新手学习。
2.搭配神经计算棒和upboard板卡能快速用于实际项目。
但是,intel的GPU毕竟较差,神经计算棒支持模型有限,在CPU和简单模型上可以使用但如果使用GPU不建议使用openVINO。

常用工具

  • 安装Intel® System Studio 2019
下载解压缩后,使用注册邮件获取激活码安装
cd /home/xs/system_studio_2019_ultimate_edition_offline
sudo ./install.sh
//启动
source /opt/intel/system_studio_2019/iss_ide_eclipse-launcher.sh
  • visual studio code
    到微软的vscode网站 (下载地址)https://code.visualstudio.com/Download ,即可安装,可以使用( 命令行输入code . 在任何目录中打开该编辑器,只用deb安装的可以命令行打开,其他不行)
    sudo dpkg -i code_1.30.0-1544567151_amd64.deb
  • sqlite可视化工具
sudo apt-get install sqlitebrowser
sqlitebroswer test.db

模型训练
服务器

你可能感兴趣的:(神经计算棒)