2023-06-24 09:35:01eugenekdd2

openvino 若何run demo applicatio

OpenVino概念
1.png

圖改自https://www.learnopencv.com/using-openvino-with-opencv/#openvino-opencv
將已練習好的深度進修model顛末Model Optimizer優化後
(何謂優化請見下面Model Optimizer條目)
經過Inference Engine  跟 硬體(CPU/ GPU /VPU)
達到加快Inference 的目的

★ Model Optimizer
      ●摘錄自:【AI_Column】運用 Intel OpenVINO 土炮自駕車視覺系統
       協助去除已練習好的模子中的冗餘參數,並可將 32bits 浮點數的參數降階,
      以犧牲數個百分點正確率來換取推論速度提拔數十倍到百倍。

   ●把深度進修框架Train出來的model, 轉換成 Inference Engine 可以用的IR file
       今朝支援的深度學習框架有 Caffe*, TensorFlow*, MXNet*, and ONNX*.
     ●之前以為所有由Caffe*, TensorFlow*, MXNet*, and ONNX* 練習出的model
     都可以由Model Optimizer轉換成IR file  ,但看了 的Supported Models章節
     彷佛不是這麼一回事,需找一個底下沒提到的model來實行看看
     有結果我再更新
      Supported Models
        For the list of supported models refer to the framework or format specific page:
•        Supported Caffe* models
•        Supported TensorFlow* models
•        Supported MXNet* models
•        Supported ONNX* models
•        Supported Kaldi* models
   ●有script可以 configure Model Optimizer  以導入
     所有OpenVino supported的深度學習框架或單一深度學習框架
       若要手動configure Model Optimizer也有文件可以參考 ->  Model Optimizer Developer Guide.

★ IR file
   包括train model的topology 跟weight,利用者只要知道如何將
   訓練好的model change to IR file,就能夠利用OpenVino加快Inference

★ Inference Engine
   用來run 最佳化後的深度進修model
   C:\Program Files (x86)\Intel\openvino_2021.4.689\
   deployment_tools\inference_engine\samples底下有放一些IE的samples   
   各Samples申明  
   延長浏覽 → 若何run Inference Engine Samples
★ VPU plugin
    這份文件似乎在講如何的model能被vpu 支援
■OpenVino不供應Model Training
   OpenVino的model起原以我的理解就以下這幾種
   1.本身用OpenVino supported的深度進修框架去train  model
      或去Model Zoo下載所需model
1.        Caffe [ Model Zoo ]
2.        Tensorflow [ Model Zoo ]
3.        MxNet [ Model zoo ] 連結失效
4.        Open Neural Network Exchange (ONNX) [ Model zoo ]
   2.OpenVino裡面附的pre-trained model  
      不過不一定有合適你需求的
   3.OpenCV DNN sample model
■相幹名詞
★ OpenVino用的是CNN( Convolutional Neural Networks )模型 ;
   還包括了Deep Learning Deployment Toolkit (Intel® DLDT).
    2.png
      Convolution:影象->filter->擷取出特徵,好比邊沿。
      此種進程叫做Convolution
★ OpenCV和OpenVX有什么联系和区别?
★ 機械進修
   機械進修理論首要是設計和闡發一些讓電腦可以主動學習的演算法。
    機械進修演算法是一類從資料中自動闡明取得紀律,並操縱紀律對未知資料進行預測的演算法。
★ 深度學習
   是機械進修的分支。 深度進修框架比較
■若何安裝OpenVino
照著 安裝步調做便可 (英文看不懂請自行降服)
-------------------------------------------------------------------------------------------------------------------------------
上述的器械都了解之後,接下來開始DEMO OpenVino附的兩個script
■Run the Image Classification Verification Script
   ★在C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\demo下
   可以找到demo_squeezenet_download_convert_run.bat。
   這個demo利用squeezenet model 判定照片中的Object屬於什麼種別
   可判斷的種別有一千種,有哪一千種可以看底下這個檔案
   C:\Program Files (x86)\Intel\openvino_2021.4.689\
   deployment_tools\demo\squeezenet1.1.labels
   *路徑中的openvino_2019.1.148的2019.1.148這數字代表版本, 是以若安裝的OpenVino版本跟我分歧,那數字也會分歧
   *若安裝不只一個版本的OpenVino,分歧版本的OpenVino會有屬於自己的資料夾
   而openvino那個捷徑會指向最後安裝的阿誰版本
    3.png
★這個batch的內容以下
   Step1 :  下載SqueezeNet model (利用downloader.py)
   Step2: 用 Model Optimizer 把SqueezeNet轉成IR file。
                (利用mo.py)
   Step3: Build Inference Engine samples
                batch檔履行過程中, 會看到cmd 畫面卡在
                Build Inference Engine samples using MS Visual Studio (MSBuild.exe)一段時候
                請耐煩等候 。此步會產生 classification_sample.exe
   Step4: 把car.png & IR file當作iInference Engine的input 來闡發car.png
   ↓This is car.png
    
4.png
   ↓針對照片中的Object,分類前十名的成果依序從Prob.高到低排列
   分類結果最高分數是sport car

   5.png
★重跑demo_squeezenet_download_convert_run.bat
   跑過一次batch之後,若再履行一次batch,
   因為某些檔案跑過一次batch以後就已存在了
   batch裡的寫法偵測到某些檔案存在以後就會疏忽掉某些Step
   若想要完全地再跑一次,需刪除以下檔案
   ●刪除model
   C:\Users\$(username)\Documents\Intel\OpenVINO\openvino_models
    \models\FP32\classification
   底下全部squeezenet 資料夾刪掉
   注意:FP32是針對CPU device的,若是VPU devide ,對應到的folder name是FP16

   ●刪除 IR       
   C:\Users\$(username)\Documents\Intel\OpenVINO\openvino_models\ir\FP32
    \classification\squeezenet\1.1\ 底下整個caffe 資料夾刪掉
   注意:FP32是針對CPU device的,若是VPU devide ,對應到的folder name是FP16
------------------------------------------------------------------------------------------------
■Run the Inference Pipeline Verification Script
★demo_security_barrier_camera.bat 這個batch的內容以下
Step1 : 下載 three pre-trained models IRs
Step2:build Security Barrier Camera Demo Inference Engine來剖析car1.bmp
Step3: 圖片裡的object會被第一個model判斷成是車輛,
              這個判定結果被看成input 導入到下一個model,
              這個model可以指出車輛的一些屬性 ex:車牌
              最後 車牌被看成input導入到第三個model,這個model可以把車牌的字元辨認出
              會被稱做Pipeline 我想應當是辨認後果從第一個model傳到第三個model
             像水流在管線裡活動一樣吧...

        
★重跑整個bat
  跑過一次batch之後,有些step會被疏忽掉,因為某些檔案已存在了
  若要乾乾淨淨的再跑一次,需要刪除以下檔案
  ●刪除 IR      
  C:\Users\$(username)\Documents\Intel\OpenVINO\openvino_models\
  ir\FP32\classification\squeezenet\1.1\
  底下整個caffe 資料夾刪掉

----------------------------------------------------------------------------------------------------------
以上範例是利用openvino在 CPU
若用其他intel 硬體, 比如movidius gpu vpu  FPGA or MYRIAD
請參考安裝文件中 Optional Steps這部份
-----------------------------------------------------------------------------------------------------------
■OpenVino PreTrained Model
★OpenVINO供給好幾個pre-trained models
可以用Model Downloader 或到
https://download.01.org/opencv/2019/open_model_zoo/ 去下載
下載的model是被優化過的model,稱作IR file( xml 檔+ bin 檔)

★可在這邊 https://docs.openvinotoolkit.org/latest/_demos_README.html
Demos that Support Pre-Trained Models章節
看各個pre-trained model support哪些Device
Object Detection Models
裡面包含好幾個model可以用來偵測object
包括:人臉,人,車輛
Object Recognition Models
用來分類或特徵辨識,利用在其他detector之後。比如先做人臉偵測,再做年齡/性別辨識

Semantic Segmentation Models
原文網址:https://kknews.cc/zh-tw/tech/mgqvl9.html
語義分割(Semantic Segmentation)的方針是給定一張圖片,對於圖片中的每一個像素做分類。
例如圖1(a)中給出的原始輸入圖片,語義分割算法對圖片中的每一個像素分類,
得到如圖1(b)的結果。在圖1(b)中,分歧色彩代表不同種別:
如紅色代表行人,藍色代表汽車,綠色代表樹,灰色代表建築物等。
語義分割問題在許多利用場景中都有著十分重要的感化(例如圖片理解,自動駕駛等)

6.png

Instance Segmentation Models
INSTANCE SEGMENTATION可以知道同類object的數量(分歧色彩默示)
https://arxiv.org/pdf/1405.0312.pdf
 8.png
9.png
Human Pose Estimation Models
Image Processing
提高影象品質
10.png

Text Detection
Action Recognition Models
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
■Trouble Shooting
● 安裝時碰到CMake*/ Python* version  xxx or higher is not detected.
       11.png

      ->Fixed by 安裝如提示的CMake & Python版本後
      再重安裝一次OpenVino
● 電腦已有安裝Python3.6.5了
      還是會泛起Python* version  xxx or higher is not detected.
      ->Fixed by 再安裝一次Python >選Modify  >勾選Add Python.....
      ->再安裝一次OpenVino就可以了

      12.png

● 執行demo_squeezenet_download_convert_run.bat前
      若沒有安裝cmake 會呈現以下Error
       'cmake' is not recognized as an internal or external command,
       operable program or batch file.
       ->Fixed by 安裝cmake
       請參考 Install CMake* 3.4 or higher章節
  ● 履行demo_squeezenet_download_convert_run.bat發生以下Err
      target_precision = FP32
      Python 3.6.6
      ECHO is off.
      PYTHONPATH=C:\Program Files (x86)\IntelSWTools\openvino\python\python3.6;
      [setupvars.bat] OpenVINO environment initialized
      INTEL_OPENVINO_DIR is set to C:\Program Files (x86)\IntelSWTools\openvino
      Python 3.6.6
      ECHO is off.
      Collecting pyyaml
      Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by       'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required (         Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )',))':                 /simple/pyyaml/
       ...
      Could not find a version that satisfies the requirement pyyaml (from versions: )
      No matching distribution found for pyyaml
      ->Fixed by 更改proxy設定
      根據Cannot connect to proxy這個訊息判定應該是proxy問題
      本來我是使用公司內網run script
      後來將proxy調劑成以下設定&連手機熱門就能夠履行了  
       13.png
  ● 出現以下Error
     ###############|| Generate VS solution for Inference Engine samples using cmake ||###############

     Waiting for 2 seconds, press a key to continue ...
     Creating Visual Studio 15 2017 x64 files in      
     C:\Users\$(userName)\Documents\Intel\OpenVINO\inference_engine_samples_build...
     CMake Error at CMakeLists.txt:7 (project):
     Generator
     Visual Studio 15 2017
     could not find any instance of Visual Studio.
     -- Configuring incomplete, errors occurred!
     ->fixed by reboot
    因為在安裝openvino之前我有開visual studio installer去 modify設定
    設定完後沒有依照唆使重開機
    因此出現以上issue
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
●其它參考連結
  - OPENvINO with openCV
  - 既跨平台又開源 英特爾開啟智慧視覺立異
    超過20個預先練習的模型,以及針對OpenCV和OpenVx的最好化電腦視覺庫。
    OpenVINO東西套件可透過CPU、GPU、FPGA、Movidius VPU(AI晶片 )等硬體進行佈置,
    增強視覺系統功能和性能
-   SqueezeNet
     SqueezeNet 是圖片分類模子,最合適參數較少及較小的模子使用,相較於現代圖片分類模型 (AlexNet),
     不會犧牲品質。
-   C:\Program Files (x86)\Intel\openvino_2021.4.689\documentation

 

 

 



參考文章
https://iam9527.pixnet.net/blog/ ... un-demo-application