# parser_generator

Python API: `depthai_nodes.node.parser_generator`

## Classes

| Name | Description |
| --- | --- |
| [`ParserGenerator`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parser_generator.md#parser_generator-Classes-ParserGenerator) | General interface for instantiating parsers based on the provided model archive. |

### class `ParserGenerator`

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

General interface for instantiating parsers based on the provided model archive.

The `build` method creates parsers based on the head information stored in the NN Archive. The method then returns a dictionary of
these parsers.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `DETECTION_PARSERS` | `set[str]` |  |
| `HOST_PARSER_ALIASES` | `dict[str, str]` |  |

Methods

| Name | Description |
| --- | --- |
| [`build`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parser_generator.md#parser_generator-Classes-ParserGenerator-build) | Instantiate parser nodes for the supplied model archive. |
| [`run`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parser_generator.md#parser_generator-Classes-ParserGenerator-run) | No-op required by `dai.node.ThreadedHostNode`. |

#### method `build`

```python
def build(
    nnArchive: dai.NNArchive,
    headIndex: int | None = None,
    hostOnly: bool = False,
) -> dict
```

Instantiate parser nodes for the supplied model archive.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `nnArchive` | `dai.NNArchive` | Model archive describing the parser configuration. | required |
| `headIndex` | `int | None` | Optional model head index to instantiate. If omitted, parsers are created for all heads. | `None` |
| `hostOnly` | `bool` | If True, use parser implementations from depthai-nodes. Otherwise, always use native DepthAI parser nodes. | `False` |

Returns

| Type | Description |
| --- | --- |
| `dict` | Mapping of model head index to parser node. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the archive has no heads, a requested parser is unavailable, or required model geometry is invalid. |
| `IndexError` | If `headIndex` is outside the archive head list. |

#### method `run`

```python
def run()
```

No-op required by `dai.node.ThreadedHostNode`.
