# embeddings

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

## Classes

### EmbeddingsParser

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.

#### Methods

##### init

```python
def __init__(self):
```

Initialize the EmbeddingsParser node.

##### build

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

Sets the head configuration for the parser.

Parameters

 * `head_config` (`dict[str, Any]`): The head configuration for the parser.

Returns

 * `EmbeddingsParser`: The parser object with the head configuration set.

##### 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); see that helper for tensor layout and validation details.

Parameters

 * `output` (`dai.NNData`): Embedding payload, typically a `dai.NNData` message.

Returns

 * `dai.NNData`: The same object passed as `output`; no copy or normalization is performed.

##### emit

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

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

Parameters

 * `output` (`dai.NNData`): Neural network output carrying tensors and source timestamps, sequence number, and optional image
   transformation.

##### extract

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

Select and dequantize the model tensors needed for parsing.

Parameters

 * `output` (`dai.NNData`): Neural network output carrying tensors and source timestamps, sequence number, and optional image
   transformation.

Returns

 * `dai.NNData`: The same NNData message, after checking that exactly one embedding output is selected.

Raises

 * `AssertionError`: If the selected embedding output count is not one.

##### run

```python
def run(self):
```

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.

##### setOutputLayerNames

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

Sets the output layer name for the parser.

Parameters

 * `output_layer_name` (`str`): The output layer name for the parser.

#### Attributes

##### output_layer_name

Name of the output layer relevant to the parser.
