# parsing_neural_network

Python API: `depthai_nodes.node.parsing_neural_network`

## Classes

| Name | Description |
| --- | --- |
| [`ParsingNeuralNetwork`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork) | Build inference with native parsers for each NN Archive head. |

### class `ParsingNeuralNetwork`

```python
class ParsingNeuralNetwork(dai.node.ThreadedHostNode)
```

Build inference with native parsers for each NN Archive head.

`build()` accepts an NN Archive, model description, or Model Zoo slug. Parser outputs preserve their native message types. Use
`HostParsingNeuralNetwork` when Python parser implementations are needed.

Properties

| Name | Type | Description |
| --- | --- | --- |
| [`input`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-input) | `dai.Node.Input` | Return the primary neural-network input. |
| [`inputs`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-inputs) | `dai.Node.InputMap` | Return the neural-network input map. |
| [`out`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-out) | `dai.Node.Output` | Return the single parser output when the model has exactly one head. |
| [`outputs`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-outputs) | `dai.Node.Output` | Neural network output having dai.MessageGroup as a payload which contains outputs of all model heads and can be accessed as a dictionary with str(model head index) as a key. |
| [`passthrough`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-passthrough) | `dai.Node.Output` | Return the primary passthrough stream from the underlying NN node. |
| [`passthroughs`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-passthroughs) | `dai.Node.OutputMap` | Return the passthrough output map from the underlying NN node. |

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-__init__) | Initialize the wrapper and create the internal neural-network node. |
| [`build`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-build) | Build the neural-network node and create parser nodes for each head. |
| [`cleanup`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-cleanup) | Cleans up the ParsingNeuralNetwork node and removes all nodes created by ParsingNeuralNetwork from the pipeline. |
| [`getNumInferenceThreads`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-getNumInferenceThreads) | Return the configured number of inference threads. |
| [`getOutput`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-getOutput) | Select an individual model-head output. |
| [`getParser`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-getParser) | Return the parser for the requested model head. |
| [`run`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-run) | Methods inherited from ThreadedHostNode. |
| [`setBackend`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-setBackend) | Forward configuration to the underlying native NeuralNetwork node. |
| [`setBackendProperties`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-setBackendProperties) | Forward configuration to the underlying native NeuralNetwork node. |
| [`setBlob`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-setBlob) | Forward configuration to the underlying native NeuralNetwork node. |
| [`setBlobPath`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-setBlobPath) | Forward configuration to the underlying native NeuralNetwork node. |
| [`setFromModelZoo`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-setFromModelZoo) | Load a model into the native network without rebuilding parsers. |
| [`setModelPath`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-setModelPath) | Forward configuration to the underlying native NeuralNetwork node. |
| [`setNNArchive`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-setNNArchive) | Set the active model archive and rebuild parser nodes. |
| [`setNumInferenceThreads`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-setNumInferenceThreads) | Forward configuration to the underlying native NeuralNetwork node. |
| [`setNumNCEPerInferenceThread`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-setNumNCEPerInferenceThread) | Forward configuration to the underlying native NeuralNetwork node. |
| [`setNumPoolFrames`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-setNumPoolFrames) | Forward configuration to the underlying native NeuralNetwork node. |
| [`setNumShavesPerInferenceThread`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Classes-ParsingNeuralNetwork-setNumShavesPerInferenceThread) | Forward configuration to the underlying native NeuralNetwork node. |

#### property `input`

```python
input: dai.Node.Input
```

Return the primary neural-network input.

#### property `inputs`

```python
inputs: dai.Node.InputMap
```

Return the neural-network input map.

#### property `out`

```python
out: dai.Node.Output
```

Return the single parser output when the model has exactly one head.

#### property `outputs`

```python
outputs: dai.Node.Output
```

Neural network output having dai.MessageGroup as a payload which contains outputs of all model heads and can be accessed as a
dictionary with str(model head index) as a key.

Can be used only when there are at least two model heads. Otherwise, out property must be used.

#### property `passthrough`

```python
passthrough: dai.Node.Output
```

Return the primary passthrough stream from the underlying NN node.

#### property `passthroughs`

```python
passthroughs: dai.Node.OutputMap
```

Return the passthrough output map from the underlying NN node.

#### method `__init__`

```python
def __init__(*args, **kwargs)
```

Initialize the wrapper and create the internal neural-network node.

#### method `build`

```python
def build(
    input: dai.Node.Output | dai.node.Camera,
    nnSource: dai.NNModelDescription | dai.NNArchive | str,
    fps: float | None = None,
) -> ParsingNeuralNetwork
```

Build the neural-network node and create parser nodes for each head.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `input` | `dai.Node.Output | dai.node.Camera` | Upstream output or camera feeding frames into the neural-network node. | required |
| `nnSource` | `dai.NNModelDescription | dai.NNArchive | str` | dai.NNModelDescription, dai.NNArchive, or HubAI model slug. | required |
| `fps` | `float | None` | Optional runtime FPS limit for the neural-network node. | `None` |

Returns

| Type | Description |
| --- | --- |
| `ParsingNeuralNetwork` | The configured node instance. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If `nnSource` is not an archive, model description, or Model Zoo slug, or its parser configuration is invalid. |

#### method `cleanup`

```python
def cleanup()
```

Cleans up the ParsingNeuralNetwork node and removes all nodes created by ParsingNeuralNetwork from the pipeline.

Must be called before removing the node from the pipeline.

#### method `getNumInferenceThreads`

```python
def getNumInferenceThreads() -> int
```

Return the configured number of inference threads.

#### method `getOutput`

```python
def getOutput(head: int) -> dai.Node.Output
```

Select an individual model-head output.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `head` | `int` | Zero-based head index from the archive. | required |

Returns

| Type | Description |
| --- | --- |
| `dai.Node.Output` | Parser output for the selected head. |

Raises

| Type | Description |
| --- | --- |
| `KeyError` | If the head is not available. |

#### method `getParser`

```python
def getParser(*args, **kwargs) -> BaseParser | dai.DeviceNode
```

Return the parser for the requested model head.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `*args` |  | Either a head index, a parser type, or a parser type and head index. |  |
| `parserType` |  | Optional expected parser type used for runtime type checking. |  |
| `index` |  | Model head index. Defaults to 0. |  |
| `**kwargs` |  | Optional `parserType` and `index` keyword arguments. |  |

Returns

| Type | Description |
| --- | --- |
| `BaseParser | dai.DeviceNode` | Parser node matching the requested head. |

Raises

| Type | Description |
| --- | --- |
| `KeyError` | If the model-head index is unavailable. |
| `TypeError` | If the parser does not match the requested parser type. |

#### method `run`

```python
def run()
```

Methods inherited from ThreadedHostNode.

Method runs with start of the pipeline.

#### method `setBackend`

```python
def setBackend(setBackend: str)
```

Forward configuration to the underlying native NeuralNetwork node.

> **Note**
> Backend and platform validation is performed by DepthAI. This forwarding method does not rebuild parser nodes.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `setBackend` | `str` | Backend identifier accepted by DepthAI. | required |

#### method `setBackendProperties`

```python
def setBackendProperties(setBackendProperties: dict[str, str])
```

Forward configuration to the underlying native NeuralNetwork node.

> **Note**
> Backend and platform validation is performed by DepthAI. This forwarding method does not rebuild parser nodes.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `setBackendProperties` | `dict[str, str]` | Backend-specific string properties. | required |

#### method `setBlob`

```python
def setBlob(blob: Path | dai.OpenVINO.Blob)
```

Forward configuration to the underlying native NeuralNetwork node.

> **Note**
> Backend and platform validation is performed by DepthAI. This forwarding method does not rebuild parser nodes.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `blob` | `Path | dai.OpenVINO.Blob` | OpenVINO blob or path accepted by DepthAI. | required |

#### method `setBlobPath`

```python
def setBlobPath(path: Path)
```

Forward configuration to the underlying native NeuralNetwork node.

> **Note**
> Backend and platform validation is performed by DepthAI. This forwarding method does not rebuild parser nodes.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `path` | `Path` | Local OpenVINO blob path. | required |

#### method `setFromModelZoo`

```python
def setFromModelZoo(description: dai.NNModelDescription, useCached: bool)
```

Load a model into the native network without rebuilding parsers.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `description` | `dai.NNModelDescription` | Model Zoo description passed to DepthAI. | required |
| `useCached` | `bool` | Whether DepthAI may reuse a cached model. | required |

#### method `setModelPath`

```python
def setModelPath(modelPath: Path)
```

Forward configuration to the underlying native NeuralNetwork node.

> **Note**
> Backend and platform validation is performed by DepthAI. This forwarding method does not rebuild parser nodes.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `modelPath` | `Path` | Local model path accepted by the native node. | required |

#### method `setNNArchive`

```python
def setNNArchive(nnArchive: dai.NNArchive, numShaves: int | None = None)
```

Set the active model archive and rebuild parser nodes.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `nnArchive` | `dai.NNArchive` | Neural-network archive containing the model and parser config. | required |
| `numShaves` | `int | None` | Optional number of shaves allocated to the neural-network node. | `None` |

#### method `setNumInferenceThreads`

```python
def setNumInferenceThreads(numThreads: int)
```

Forward configuration to the underlying native NeuralNetwork node.

> **Note**
> Backend and platform validation is performed by DepthAI. This forwarding method does not rebuild parser nodes.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `numThreads` | `int` | Requested number of parallel inference threads. | required |

#### method `setNumNCEPerInferenceThread`

```python
def setNumNCEPerInferenceThread(numNCEPerThread: int)
```

Forward configuration to the underlying native NeuralNetwork node.

> **Note**
> Backend and platform validation is performed by DepthAI. This forwarding method does not rebuild parser nodes.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `numNCEPerThread` | `int` | Number of neural compute engines allocated per inference thread. | required |

#### method `setNumPoolFrames`

```python
def setNumPoolFrames(numFrames: int)
```

Forward configuration to the underlying native NeuralNetwork node.

> **Note**
> Backend and platform validation is performed by DepthAI. This forwarding method does not rebuild parser nodes.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `numFrames` | `int` | Number of frames in the network output pool. | required |

#### method `setNumShavesPerInferenceThread`

```python
def setNumShavesPerInferenceThread(numShavesPerInferenceThread: int)
```

Forward configuration to the underlying native NeuralNetwork node.

> **Note**
> Backend and platform validation is performed by DepthAI. This forwarding method does not rebuild parser nodes.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `numShavesPerInferenceThread` | `int` | Number of SHAVE cores allocated per inference thread. | required |

## Module Attributes

| Name | Description |
| --- | --- |
| [`TParser`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsing_neural_network.md#parsing_neural_network-Module-Attributes-TParser) |  |

### type variable `TParser`

```python
TParser = TypeVar('TParser', bound=BaseParser | dai.DeviceNode)
```
