前面在 OpenVINO 2020的INT8轉換工具POT的初體驗 里面分享了一下POT和accuracy_check工具的用法,但是用的是分類classification模型,相對比較簡單,今天簡單分享一下寫檢測ssd模型精度的config檔案的思路
首先要罵娘的是OpenVINO的檔案寫的極其差,幾乎是找不到任何你想要的東西。也許這就是開源專案的精髓,一切全靠看代碼... 所以先想一下,在我用DL workbench的時候,可以轉換mobilenet-ssd模型和測驗模型精度。所以這部分肯定是帶在openvino安裝目錄里了,翻翻openvino accuracy_checker的目錄,看到了一個可疑的檔案

看一下檔案內容
models:
- name: ssd-mobilenet-cf
launchers:
- framework: caffe
model: public/mobilenet-ssd/mobilenet-ssd.prototxt
weights: public/mobilenet-ssd/mobilenet-ssd.caffemodel
adapter: ssd
datasets:
- name: VOC2012
preprocessing:
- type: resize
size: 300
- type: normalization
mean: 127.5
std: 127.5
postprocessing:
- type: resize_prediction_boxes
- name: ssd-mobilenet
launchers:
- framework: dlsdk
tags:
- FP32
model: public/mobilenet-ssd/FP32/mobilenet-ssd.xml
weights: public/mobilenet-ssd/FP32/mobilenet-ssd.bin
adapter: ssd
- framework: dlsdk
tags:
- FP16
model: public/mobilenet-ssd/FP16/mobilenet-ssd.xml
weights: public/mobilenet-ssd/FP16/mobilenet-ssd.bin
adapter: ssd
datasets:
- name: VOC2012
preprocessing:
- type: resize
size: 300
postprocessing:
- type: resize_prediction_boxes
global_definitions: ../dataset_definitions.yml
有launchers部分,里面有模型的路徑和檔案名;有datasets部分,寫著資料集是VOC2012, 底下描述的部分不太全。但是下面有一句奇怪的東東: global_definitions: ../dataset_definitions.yml
看上去有點像C語言的include, 看看這個檔案

檔案內容里找VOC2012的關鍵字
- name: VOC2012
annotation_conversion:
converter: voc_detection
annotations_dir: VOCdevkit/VOC2012/Annotations
images_dir: VOCdevkit/VOC2012/JPEGImages
imageset_file: VOCdevkit/VOC2012/ImageSets/Main/val.txt
data_source: VOCdevkit/VOC2012/JPEGImages
annotation: voc12.pickle
dataset_meta: voc12.json
postprocessing:
- type: resize_prediction_boxes
metrics:
- type: map
integral: 11point
ignore_difficult: True
presenter: print_scalar
這個大概就全了,新建一個mobilenet-ssd_ac.yml檔案,用Ctrl CV大法,把我想要的東西都拷貝粘貼在一起
models:
- name: ssd-mobilenet
launchers:
- framework: dlsdk
tags:
- FP32
model: mobilenet-ssd.xml
weights: mobilenet-ssd.bin
adapter: ssd
datasets:
- name: VOC2012
preprocessing:
- type: resize
size: 300
postprocessing:
- type: resize_prediction_boxes
annotation_conversion:
converter: voc_detection
annotations_dir: VOCdevkit/VOC2012/Annotations
images_dir: VOCdevkit/VOC2012/JPEGImages
imageset_file: VOCdevkit/VOC2012/ImageSets/Main/val.txt
data_source: VOCdevkit/VOC2012/JPEGImages
annotation: voc12.pickle
dataset_meta: voc12.json
postprocessing:
- type: resize_prediction_boxes
metrics:
- type: map
integral: 11point
ignore_difficult: True
presenter: print_scalar
然后轉換mobilenet-ssd的IR模型
C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer>python mo_caffe.py --input_model c:\work\cvt_model\mobilenet-ssd.caffemodel -o c:\work\mobilenet-ssd_ac --scale 127.5 --mean_values [127.5,127.5,127.5]
再從網上下一個VoC模型 VOCtrainval_11-May-2012.tar
把這幾個檔案放到一起

運行一下看看

mAP精度是79.84% 基本可以證明這個config檔案是寫對了 :)
總結一下:
在C:\Program Files (x86)\IntelSWTools\openvino_2020.3.194\deployment_tools\open_model_zoo\tools\accuracy_checker\configs下面有很多預先寫好的開源模型精度檢查組態檔,寫自己的模型檢測配置的時候可以拿來參考一下 :)
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/135621.html
標籤:英特爾技術
上一篇:OpenVINO Model Optimizer轉換時的預處理preprocess
下一篇:Qt多執行緒退出問題
