# embeddings

Python API: `depthai_nodes.node.parsers.embeddings`

## Classes

| Name | Description |
| --- | --- |
| [`EmbeddingsParser`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/embeddings.md#embeddings-Classes-EmbeddingsParser) | Parser class for parsing the output of embeddings neural network model head. |

### class `EmbeddingsParser`

```python
class EmbeddingsParser(BaseParser)
```

Parser class for parsing the output of embeddings neural network model head.

> **Note**
> Emits `dai.NNData` messages. The output layer of the neural network model head.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `output_layer_name` | `str | None` | Name of the output layer relevant to the parser. |

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/embeddings.md#embeddings-Classes-EmbeddingsParser-__init__) | Initialize the EmbeddingsParser node. |
| [`build`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/embeddings.md#embeddings-Classes-EmbeddingsParser-build) | Sets the head configuration for the parser. |
| [`compute`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/embeddings.md#embeddings-Classes-EmbeddingsParser-compute) | Compute parser results from extracted tensors without sending messages. |
| [`emit`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/embeddings.md#embeddings-Classes-EmbeddingsParser-emit) | Forward the same NNData message on `out`, preserving its metadata. |
| [`extract`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/embeddings.md#embeddings-Classes-EmbeddingsParser-extract) | Select and dequantize the model tensors needed for parsing. |
| [`run`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/embeddings.md#embeddings-Classes-EmbeddingsParser-run) | Read queued network outputs, parse them, and emit results while running. |
| [`setOutputLayerNames`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/embeddings.md#embeddings-Classes-EmbeddingsParser-setOutputLayerNames) | Sets the output layer name for the parser. |

#### method `__init__`

```python
def __init__()
```

Initialize the EmbeddingsParser node.

#### method `build`

```python
def build(head_config: dict[str, Any]) -> EmbeddingsParser
```

Sets the head configuration for the parser.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `head_config` | `dict[str, Any]` | The head configuration for the parser. | required |

Returns

| Type | Description |
| --- | --- |
| `EmbeddingsParser` | The parser object with the head configuration set. |

#### static method `compute`

```python
def compute(output: dai.NNData) -> dai.NNData
```

Compute parser results from extracted tensors without sending messages.

> **Note**
> Uses [depthai_nodes.node.parsers.utils.embeddings.compute_embeddings_output](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/embeddings.md#embeddings-Functions-compute_embeddings_output); see that helper for tensor layout and validation details.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output` | `dai.NNData` | Embedding payload, typically a `dai.NNData` message. | required |

Returns

| Type | Description |
| --- | --- |
| `dai.NNData` | The same object passed as `output`; no copy or normalization is performed. |

#### method `emit`

```python
def emit(output: dai.NNData)
```

Forward the same NNData message on `out`, preserving its metadata.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output` | `dai.NNData` | Neural network output carrying tensors and source timestamps, sequence number, and optional image transformation. | required |

#### method `extract`

```python
def extract(output: dai.NNData) -> dai.NNData
```

Select and dequantize the model tensors needed for parsing.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output` | `dai.NNData` | Neural network output carrying tensors and source timestamps, sequence number, and optional image transformation. | required |

Returns

| Type | Description |
| --- | --- |
| `dai.NNData` | The same NNData message, after checking that exactly one embedding output is selected. |

Raises

| Type | Description |
| --- | --- |
| `AssertionError` | If the selected embedding output count is not one. |

#### method `run`

```python
def run()
```

Read queued network outputs, parse them, and emit results while running.

The pipeline invokes this processing loop. It exits when the input queue closes or the node stops.

#### method `setOutputLayerNames`

```python
def setOutputLayerNames(output_layer_name: str)
```

Sets the output layer name for the parser.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output_layer_name` | `str` | The output layer name for the parser. | required |
