YOLO模型训练=》OPENVINO部署
简单整理了冲模型训练到openvino部署的相关内容。
YOLO模型的训练
1.下载darknet,进行编译。安装cuda、opencv、cudnn。
2.lable标注工具下载:
git地址:https://github.com/tzutalin/labelImg
3.训练数据准备
git地址:https://gitee.com/qiaokuankuan/object_detection.git
4.预训练模型参数下载,yolov3
git地址:https://pjreddie.com/media/files/darknet53.conv.74
5.训练模型
标注训练数据的lable
确认训练数据的类别:classes.txt
获取训练数据的文件列表:trainlist.txt
修改配置文件:voc.data
修改配置模型cfg文件:yolov3-voc.cfg
模型训练:
./darknet detector train /home/bhc/darknet-master/qkk/16/train/voc.data /home/bhc/darknet-master/qkk/16/train/yolov3-voc.cfg darknet53.conv.74
6.模型转换,yolo->pb
git地址:https://gitcode.net/mirrors/mystic123/tensorflow-yolo-v3
python3 ./convert_weights_pb.py --class_names /home/bhc/darknet-master/qkk/16/train/classes.txt --data_format NHWC --weights_file /home/bhc/darknet-master/backup1/16/16.weights
7.模型转换,PB->IR
python3 /opt/intel/openvino_2021/deployment_tools/model_optimizer/mo_tf.py \ --input_model frozen_darknet_yolov3_model.pb \ --transformations_config yolo_v3.json \ --batch 1 \ --reverse_input_channels
8.openvino模型部署
9.gstreamer部署
#!/bin/bash set -eu videofile="video/D16_operator/D16_20211025135235.mp4" process_width=1920 process_height=1080 shrink_rate=1 # 1920/1920 frame_rate=29 yolo_threshold=0.9 paramjson=$(cat << EOS { \"shrink_rate\": ${shrink_rate}, \"frame_rate\": ${frame_rate} } EOS ) gst-launch-1.0 filesrc location=${videofile} \ ! decodebin \ ! videoconvert \ ! videoscale \ ! capsfilter caps="video/x-raw,width=${process_width},height=${process_height},frame_rate=${frame_rate/1},format=BGRx" \ ! queue \ ! gvadetect model=/home/bhc/darknet-master/backup1/16/16.xml model-proc=model/D16_operator/procd16_yolo-v3.json threshold=${yolo_threshold} inference-interval=10 \ ! queue \ ! gvatrack tracking-type=short-term \ ! queue \ ! gvawatermark \ ! videoconvert \ ! xvimagesink sync=false
天道酬勤 循序渐进 技压群雄