NeuralNetwork
.blob 格式才能与 VPU 兼容。关于如何将神经网络(NN)编译为 .blob 的说明,请参见此处。如何放置
Python
Python
1pipeline = dai.Pipeline()
2nn = pipeline.create(dai.node.NeuralNetwork)输入和输出
Passthrough 机制
使用
Python
Python
1pipeline = dai.Pipeline()
2nn = pipeline.create(dai.node.NeuralNetwork)
3nn.setBlobPath(bbBlobPath)
4cam.out.link(nn.input)
5
6# Send NN out to the host via XLink
7nnXout = pipeline.create(dai.node.XLinkOut)
8nnXout.setStreamName("nn")
9nn.out.link(nnXout.input)
10
11with dai.Device(pipeline) as device:
12 qNn = device.getOutputQueue("nn")
13
14 nnData = qNn.get() # Blocking
15
16 # NN can output from multiple layers. Print all layer names:
17 print(nnData.getAllLayerNames())
18
19 # Get layer named "Layer1_FP16" as FP16
20 layer1Data = nnData.getLayerFp16("Layer1_FP16")
21
22 # You can now decode the output of your NN功能示例
参考
class
depthai.node.NeuralNetwork(depthai.Node)
method
getNumInferenceThreads(self) -> int: intHow many inference threads will be used to run the network Returns: Number of threads, 0, 1 or 2. Zero means AUTO
method
method
setBlobPath(self, path: Path)Load network blob into assets and use once pipeline is started. Throws: Error if file doesn't exist or isn't a valid network blob. Parameter ``path``: Path to network blob
method
setNumInferenceThreads(self, numThreads: typing.SupportsInt)How many threads should the node use to run the network. Parameter ``numThreads``: Number of threads to dedicate to this node
method
setNumNCEPerInferenceThread(self, numNCEPerThread: typing.SupportsInt)How many Neural Compute Engines should a single thread use for inference Parameter ``numNCEPerThread``: Number of NCE per thread
method
setNumPoolFrames(self, numFrames: typing.SupportsInt)Specifies how many frames will be available in the pool Parameter ``numFrames``: How many frames will pool have
property
input
Input message with data to be inferred upon Default queue is blocking with size 5
property
inputs
Inputs mapped to network inputs. Useful for inferring from separate data sources Default input is non-blocking with queue size 1 and waits for messages
property
out
Outputs NNData message that carries inference results
property
passthrough
Passthrough message on which the inference was performed. Suitable for when input queue is set to non-blocking behavior.
property
passthroughs
Passthroughs which correspond to specified input
需要帮助?
请前往 OAKChina 官网 获取技术支持或解答您的任何疑问。