zoukankan      html  css  js  c++  java
  • 英特尔神经棒使用入门-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 传送门

      

  • 相关阅读:
    Android:CheckBox控件
    Android:RadioGroup,RadioButton
    Android:ImageView控件显示图片
    Spark:reduceByKey函数的用法
    HIve:beeline终端上在输错hive语句时,无论 Backspace还是delete 都删除不掉错误的语句,没有办法退格
    orchard-1.9.2-1.10.2汉化
    Hive:表1inner join表2结果group by优化
    hive:某张表进行分页
    hive:创建索引
    Android:后台给button绑定onClick事件、当返回项目到手机页面时提示是否退出APP
  • 原文地址:https://www.cnblogs.com/CXianRen/p/10650035.html
Copyright © 2011-2022 走看看