英特爾神經棒使用入門-NCS2 & NCS1 -OpenVino


|--背景:

  NCS1使用的NCSDK1和NCSDK2,速度一般,沒有想象中的速度,能有TX2一半的速度吧。跟大佬又申請了個NCS2來試一試。

  環境配置到跑通自己寫的MNIST分類網絡花了2天不到吧。

|--總結:

  Openvino和之前的NCSDK比算是有很大的進步了。文檔都比較全,但是都有文檔跟不上版本的問題。

|--環境:

|----Ubuntu16.04 + Openvino R5 2018-5

  Openvino的安裝,按照Intel官網上一步一步走的,沒什么大問題。

  可能安裝和跑demo的過程中可能出現的問題:

  1、使用腳本安裝依賴包時可能會有錯誤,把對於錯誤的行注釋,手動安裝即可

  2、對於上述問題可能原因是源的問題,可以嘗試更換一下源,

  3、如腳本執行sudo apt -E updata 報錯,可以在確定系統更新到最新后將改行注釋掉,

  4、安裝python-ven 錯誤,手動安裝個虛擬環境即可

  5、提示xxx.so不是鏈接文件,重新做一下鏈接即可(或者在google上找這個報錯,overstack中有解決方案,沒保存,挺好找的)

 

|----demo& 自定義網絡的使用

  1、demo按照官網的步驟即可,主要是如何使用子定義的網絡。

  2、使用自定義的網絡openvino中沒有講,但是應為硬件就是這個了,和NCSDK的要求必然相差不遠的按照NCSDK中修改網絡即可:https://movidius.github.io/ncsdk/tf_compile_guidance.html

  3、修改並訓練好后,如何編譯到Openvino的格式:xml & bin :在Openvino中有講如何載入bp文件或者meta文件。可能會遇到的錯誤 如 入口節點 的未完全定義呀什么,解決方法加入參數: --batch 1 或者 --input_size [x,x,x,x],參考鏈接:https://software.intel.com/en-us/forums/computer-vision/topic/801113

  4、使用網絡參考其中的不完全代碼和 Python 接口文檔:鏈接 https://software.intel.com/en-us/articles/transitioning-from-intel-movidius-neural-compute-sdk-to-openvino-toolkit

python接口demo:

 1 import openvino.inference_engine as ie 
 2 import cv2
 3 import numpy
 4 import time
 5 def main():
 6     #######################  Device  Initialization  ########################
 7     #  Plugin initialization for specified device and load extensions library if specified
 8     plugin = ie.IEPlugin(device="MYRIAD")
 9     #########################################################################
10 
11     #########################  Load Neural Network  #########################
12     #  Read in Graph file (IR)
13     net = ie.IENetwork(model="mnist_inference.xml", weights="mnist_inference.bin")
14 
15     input_blob = next(iter(net.inputs))
16     out_blob = next(iter(net.outputs))
17     #  Load network to the plugin
18     exec_net = plugin.load(network=net)
19     del net
20     ########################################################################
21 
22     #########################  Obtain Input Tensor  ########################
23     #  Obtain and preprocess input tensor (image)
24     #  Read and pre-process input image  maybe we don't need to show these details
25     image_for_inference = cv2.imread("./1.JPG")
26     
27     image_for_inference = cv2.cvtColor(image_for_inference, cv2.COLOR_BGR2GRAY)
28     image_for_inference=cv2.resize(image_for_inference, (28,28))
29 
30     image_for_inference = image_for_inference.astype(numpy.float32)
31 
32     image_for_inference[:] =1-((image_for_inference[:] )*(1.0/255.0))
33 
34     image_for_inference=image_for_inference.reshape(-1,1,784)
35     # ########################################################################
36 
37     # ##########################  Start  Inference  ##########################
38     # #  Start synchronous inference and get inference result
39     ct=time.time()
40     req_handle = exec_net.start_async(0,inputs={input_blob:image_for_inference})
41     # # ########################################################################
42     # res = exec_net.infer({input_blob:image_for_inference})
43     # # ######################## Get Inference Result  #########################
44     status = req_handle.wait()
45     res = req_handle.outputs[out_blob]
46 
47 
48     # Do something with the results... (like print top 5)
49     print(time.time()-ct)
50     print(res[0])
51     print((1-res[0]).argsort()[:1])
52     # ###############################  Clean  Up  ############################
53     del exec_net
54     del plugin
55     # ########################################################################
56 
57 import sys
58 if __name__ == '__main__':
59     sys.exit(main() or 0)

github 傳送門

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM