Open junxnone opened 4 years ago
基于 OpenVINO 2019.R3 文档
Python API
C++ API
cython
so
2019.R2 引入,与IEPlugin 有部分重复
ie = IECore() ie.add_extension(extension_path="/some_dir/libcpu_extension_avx2.so", device_name="CPU")
ie = IECore() ie.get_metric(metric_name="SUPPORTED_METRICS", device_name="CPU")
IENetwork
net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file) ie = IECore() exec_net = ie.load_network(network=net, device_name="CPU", num_requsts=2)
net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file) ie = IECore() layers_map = ie.query_network(network=net, device_name="HETERO:GPU,CPU")
ie = IECore() ie.register_plugin(plugin="MKLDNNPlugin", device_name="MY_NEW_PLUGIN")
ie = IECore() ie.register_plugins("/localdisk/plugins/my_custom_cfg.xml")
ie = IECore() plugin = IEPlugin("GPU") ie.register_plugin(plugin=plugin, device_name="MY_NEW_GPU") ie.unregister_plugin(device_name="GPU")
net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file)
net.batch_size = 4
net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file) input_layer = next(iter(net.inputs)) n, c, h, w = net.inputs[input_layer] net.reshape({input_layer: (n, c, h*2, w*2)}]
net = IENetwork(model=path_to_model, weights=path_to_weights) net.serialize(path_to_xml, path_to_bin)
获取执行 graph 信息
net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file) plugin = IEPlugin(device="CPU") exec_net = plugin.load(network=net, num_requsts=2) exec_graph = exec_net.get_exec_graph_info()
获取 runtime metric
ie = IECore() net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file) exec_net = ie.load_network(net, "CPU") exec_net.get_metric("NETWORK_NAME")
sync inference
net = IENetwork(model=path_to_xml_file, weights=path_to_bin_file) plugin = IEPlugin(device="CPU") exec_net = plugin.load(network=net, num_requests=2) res = exec_net.infer({'data': img}) res {'prob': array([[[[2.83426580e-08]], [[2.40166020e-08]], [[1.29469613e-09]], [[2.95946148e-08]] ...... ]])}
aync inference
infer_request_handle = exec_net.start_async(request_id=0, inputs={input_blob: image}) infer_status = infer_request_handle.wait() res = infer_request_handle.outputs[out_blob_name]
junxnone/AI#63
Python API
是调用的C++ API
, 使用cython
编译为so
文件Reference
Python Classes
IECore
IENetwork
定义IENetwork
ExecutableNetwork
获取执行 graph 信息
获取 runtime metric
sync inference
aync inference
Python API & C++ API
Python Samples