欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

OpenVINO如何實(shí)現(xiàn)Robomaster自瞄

今天就跟大家聊聊有關(guān)OpenVINO如何實(shí)現(xiàn)Robomaster自瞄,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

為烏蘇等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及烏蘇網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、外貿(mào)營(yíng)銷網(wǎng)站建設(shè)、烏蘇網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!

在Robomaster比賽中,選手往往使用顏色分離,提取輪廓,匹配輪廓的方式來(lái)識(shí)別裝甲板,但往往會(huì)花費(fèi)大量時(shí)間在現(xiàn)場(chǎng)調(diào)整參數(shù),于是我們想:能否利用深度學(xué)習(xí)來(lái)做自瞄以提高其魯棒性?但深度學(xué)習(xí)算法在實(shí)時(shí)性上通常表現(xiàn)不好,在1080ti這樣的顯卡才能達(dá)到實(shí)時(shí),但沒(méi)人會(huì)在機(jī)器人上帶一個(gè)煤氣灶吧。很多人會(huì)想到使用Tensor RT,或者模型剪枝/壓縮,低比特推理的方式提高深度學(xué)習(xí)算法在GPU上的速度,但沒(méi)有想到使用純CPU也能實(shí)時(shí)運(yùn)行神經(jīng)網(wǎng)絡(luò)。憑借Intel團(tuán)隊(duì)發(fā)布的openvino,我們可以在Intel CPU或者計(jì)算棒上實(shí)時(shí)運(yùn)行目標(biāo)檢測(cè)算法。在這里我們以CPU+計(jì)算棒的方式介紹完整的實(shí)現(xiàn)步驟。How it works?分為三個(gè)步驟

  1. 訓(xùn)練自己的模型或者使用官方的demo
  2. 將模型轉(zhuǎn)換至中間表示層
  3. 部署      OpenVINO如何實(shí)現(xiàn)Robomaster自瞄根據(jù)官網(wǎng)上的信息,openvino對(duì)TensorFlow支持的最好,所以我們這里以谷歌的模型庫(kù)為示例,走通上述的pipeline。      OpenVINO如何實(shí)現(xiàn)Robomaster自瞄
檢測(cè)demo
 

1  訓(xùn)練自己的模型

本節(jié)以robomaster數(shù)據(jù)集為例,利用TensorFlow Object Detection API訓(xùn)練自己的模型。

 

1.1 使用的模型庫(kù)

鏈接:https://github.com/tensorflow/models/tree/master/research/object_detection

TensorFlow Object Detection API是谷歌爸爸開(kāi)源的模型庫(kù),包含了完整的訓(xùn)練和評(píng)測(cè)代碼。

模型包括主流的檢測(cè)和分割網(wǎng)絡(luò),有SSD,F(xiàn)aster rcnn,mask rcnn,主干網(wǎng)包括mobilenet v1/v2/v3(看出谷歌爸爸的偏心了吧),inception v2,resnet 50/101。

OpenVINO如何實(shí)現(xiàn)Robomaster自瞄
SSD家族,map代表檢     測(cè)準(zhǔn)確度,越大越好
 

1.2 數(shù)據(jù)集

大疆在2020年初開(kāi)源了一個(gè)俯視視角的數(shù)據(jù)集,具體特征類似于大家看直播時(shí)的畫面。分辨率是1920*1080。官方的用意應(yīng)該是給雷達(dá)站做目標(biāo)檢測(cè),放在自瞄這樣的平視場(chǎng)景會(huì)存在一定的gap,同時(shí)分辨率也過(guò)大,增大計(jì)算負(fù)擔(dān)。所以我們?cè)诠俜綌?shù)據(jù)集的基礎(chǔ)上進(jìn)行了魔改,改動(dòng)如下:

  1. 檢測(cè)紅色裝甲板和藍(lán)色裝甲板
  2. 為了方便評(píng)測(cè),我們將原有的VOC數(shù)據(jù)集格式改為COCO格式
  3. 對(duì)原圖進(jìn)行crop操作。針對(duì)一張圖的每一個(gè)物體,先給該物體中心點(diǎn)一個(gè)30個(gè)像素點(diǎn)以內(nèi)的上下左右漂移,然后以此點(diǎn)為中心,扣取400*300的圖像
OpenVINO如何實(shí)現(xiàn)Robomaster自瞄

裝甲板非常小    
OpenVINO如何實(shí)現(xiàn)Robomaster自瞄
裝甲板可見(jiàn)

下載鏈接:https://pan.baidu.com/s/105vjTcDs6XZHtnXAgCx86g 提取碼:v8yg

 

1.3  訓(xùn)練+評(píng)測(cè)

Prerequisite:顯卡:最好1080ti以上。單卡v100兩個(gè)小時(shí)訓(xùn)練完畢。

pip install tensorflow-gpu==1.14 最好使用1.14版本的TF

Linux系統(tǒng)

 
1.3.1 安裝TensorFlow Object Detection API

請(qǐng)參考 官方安裝指令:https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

 
1.3.2 修改配置文件
  1. 將coco數(shù)據(jù)集轉(zhuǎn)換為tfrecord格式
python object_detection/dataset_tools/create_coco_tf_record.py --logtostderr \
  --train_image_dir="data/roco_train" \
  --val_image_dir="data/roco_val" \
  --test_image_dir="data/roco_val" \
  --train_annotations_file="data/train.json" \
  --val_annotations_file="data/val.json" \
  --testdev_annotations_file="data/val.json" \
  --output_dir="models/research/save_dir"
 

目錄根據(jù)自己的實(shí)際位置更改,其中test可以忽略

  1. 模型config

所有模型配置文件在models/research/object_detection/samples/configs目錄下,以ssd_mobilenet_v2_coco.config為例。

需要修改的地方①num_classes: 2 ②image_resizer:height: 300 width: 400 ③fine_tune_checkpoint ④最后的數(shù)據(jù)位置 數(shù)據(jù)擴(kuò)充:水平翻轉(zhuǎn),亮度,對(duì)比度,飽和度隨機(jī)抖動(dòng)

  data_augmentation_options {
    random_horizontal_flip {
    }
  }
  data_augmentation_options {
    random_adjust_brightness {
      max_delta: 0.2
    }
  }
  data_augmentation_options {
    random_adjust_contrast {
      min_delta: 0.7
      max_delta: 1.1
    }
  }
  data_augmentation_options {
    random_adjust_saturation {
      min_delta: 0.9
      max_delta: 1.1
    }
  }
 
  1. 數(shù)據(jù)config

在models/research/object_detection/data/*.pbtxt里記錄了數(shù)據(jù)集的類別,這里我們是兩類,所以將label_map_path中的文件替換為以下字段:(注意文件名對(duì)應(yīng))

item {
  name: "/m/01g317"
  id: 1
  display_name: "armor_blue"
}
item {
  name: "/m/0199g"
  id: 2
  display_name: "armor_red"
}
 

訓(xùn)練代碼

export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
CUDA_VISIBLE_DEVICES=0 python object_detection/model_main.py \
--pipeline_config_path=object_detection/samples/configs/ssd_mobilenet_v2_coco.config \
    --model_dir='output_model' \
    --num_train_steps=500000 \
    --sample_1_of_n_eval_examples=10 \
    --alsologtostderr
 

v100訓(xùn)練2個(gè)小時(shí)就收斂了,1080ti可能三小時(shí)。訓(xùn)練過(guò)程中會(huì)邊訓(xùn)練邊評(píng)測(cè)。

這里我們關(guān)注的是mAP(0.5:0.95)和AP(0.5),可以看到mAP是0.537,AP是0.974,基本滿足需求。

 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.537
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.974
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.531
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.529
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.613
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.220
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.618
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.619
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.607
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.684
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
 

當(dāng)然,我們也放出來(lái)了模型文件

下載鏈接:百度云:https://pan.baidu.com/s/1-m1ovofM_X9rh5rlQEicFg 提取碼:4nra

 

2  Openvino模型轉(zhuǎn)換

 

2.1 安裝openvino

在Linux下的安裝請(qǐng)參閱 官方文檔(很簡(jiǎn)單):https://docs.openvinotoolkit.org/latest/_docs_install_guides_installing_openvino_linux.html

同時(shí)還可以查看 b站視頻:https://www.bilibili.com/video/BV1fC4y1s7dt

 

2.2 模型轉(zhuǎn)換

仍然在TensorFlow models文件夾下,先提取inference_graph

python object_detection/export_inference_graph.py \
--input_type=image_tensor \ 
--pipeline_config_path=object_detection/samples/configs/ssdlite_mobilenet_v2_coco.config \ --trained_checkpoint_prefix=models/research/output_model/model.ckpt-18723 \--output_directory=models/research/exported_model
 

將inference_graph轉(zhuǎn)換為openvino接受的格式也就是intermediate representation。這里需要注意ssd mobilenetv2對(duì)應(yīng)的是ssd_support_api_v1.15.json

python3 mo_tf.py --input_model=exported_model/frozen_inference_graph.pb --transformations_config /opt/intel/openvino/deployment_tools/model_optimizer/extensions/front/tf/ssd_support_api_v1.15.json --tensorflow_object_detection_api_pipeline_config exported_model/pipeline.config --reverse_input_channels 
 

Python測(cè)試模型

python3 object_detection_demo_ssd_async.py -m /home/lilelife/onnx/ssdv2/frozen_inference_graph.xml -i *.avi
 

C艸測(cè)試模型(記得先編譯源碼)

./object_detection_demo_ssd_async -i *.mp4 -m ssdv2/frozen_inference_graph.xml
 

結(jié)果就是開(kāi)頭的GIF啦。

看完上述內(nèi)容,你們對(duì)OpenVINO如何實(shí)現(xiàn)Robomaster自瞄有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。

當(dāng)前文章:OpenVINO如何實(shí)現(xiàn)Robomaster自瞄
URL標(biāo)題:http://www.chinadenli.net/article48/iigeep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗(yàn)云服務(wù)器全網(wǎng)營(yíng)銷推廣微信公眾號(hào)網(wǎng)站建設(shè)面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司