NCSDK(Movidius SDK) 与 OpenVINO
文章目录
NCS | NCS2 | 说明 | |
---|---|---|---|
出品公司 | Movidius | Intel | 以色列公司 Movidius 在 2016 年被 Intel 收购 |
架构 | Mygrid 2 VPU | Mygrid X VPU | Mygrid X VPU 全名为 Intel®Movidius™Myriad™X VPU |
计算核心数 | 12 核 | 16 核 | |
深度神经网络推理 | 专用硬件加速 |
NCSDK(Movidius SDK) | OpenVINO | 说明 | |
---|---|---|---|
公司 | 原 Movidius 公司开发,后被 Intel 收购 | Intel 公司 | |
对 NCS 支持 | NCSDK v1/v2 仅支持一代 NCS | 支持 NCS 和 NCS2 | NCSDK v1 与 NCSDK v2 互不兼容。 NCSDK v1 基本已被弃用。 OpenVINO 实际包含 Movidius SDK |
功能 | 只做编码、解码的加速 | 集成 OpenCV、OpenVX 的支持 | |
支持框架 | Caffe、TensorFlow | Caffe、TensorFlow、MXNet、Kaldi、ONNX | |
API 接口 | C、Python | C++、Python | |
多 NCS 设备 | 提供 NCS 列表,用户决定在特定设备上推理 | 根据设备负载向 NCS 设备分发推理任务,无需管理 NCS 设备 | |
限制 | 目前支持的 ARM 设备:树莓派(Raspberry) | ||
支持设备 | NCS | Intel CPU、NCS、NCS2、Movidius VPU、Intel GPU、FPGA |
Python - NCAPI v2
"""NCAPI v2"""
### initialization
from mvnc import mvncapi
######################## Device Initialization #######################
device_list = mvncapi.enumerate_devices()
device = mvncapi.Device(device_list[0])
device.open()
########################################################################
####################### Load Neural Network ########################
# Initialize a graph from file at some GRAPH_FILEPATH
GRAPH_FILEPATH = './graph'
with open(GRAPH_FILEPATH, mode='rb') as f:
graph_buffer = f.read()
graph = mvncapi.Graph('graph1')
# CONVENIENCE FUNCTION:
# Allocate the graph to the device and create input/output Fifos with default options in one call
input_fifo, output_fifo = graph.allocate_with_fifos(device, graph_buffer
########################################################################
######################## Obtain Input Tensor #########################
# Read and pre-process input (data type must match input Fifo data type)
input_tensor = ...
########################################################################
######################### Start Inference #########################
# CONVENIENCE FUNCTION:
# Write the image to the input queue and queue the inference in one call
graph.queue_inference_with_fifo_elem(input_fifo, output_fifo, input_tensor, None)
########################################################################
######################### Get Inference result #######################
# Get the results from the output queue
output, user_obj = output_fifo.read_elem()
########################################################################
# Do something with the results...
############################# Clean up ###############################
input_fifo.destroy()
output_fifo.destroy()
graph.destroy()
device.close()
device.destroy()
########################################################################
Python - OpenVINO™ Toolkit
def main():
####################### Device Initialization ########################
# Plugin initialization for specified device and load extensions library if specified
plugin = IEPlugin(device="MYRIAD")
#########################################################################
######################### Load Neural Network #########################
# Read in Graph file (IR)
net = IENetwork.from_ir(model="graph1.xml"