# inferer

Python API: `modelconverter.platforms.hailo.inferer`

Inference with a Hailo model through the Hailo SDK.

Holds the
[Inferer](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/base_inferer.md#base_inferer-Classes-Inferer)
implementation the `infer` command uses for the Hailo platform: the converted HAR model is loaded with `hailo_sdk_client` and run
in the SDK's quantized inference context. It only works inside the Hailo Docker image, where that SDK is installed.

## Classes

| Name | Description |
| --- | --- |
| [`HailoInferer`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/hailo/inferer.md#inferer-Classes-HailoInferer) | Inferer for Hailo HAR models based on the Hailo SDK client. |

### class `HailoInferer`

```python
class HailoInferer(Inferer)
```

Inferer for Hailo HAR models based on the Hailo SDK client.

Methods

| Name | Description |
| --- | --- |
| [`infer`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/hailo/inferer.md#inferer-Classes-HailoInferer-infer) | Run the model on a single set of input files. |
| [`setup`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/hailo/inferer.md#inferer-Classes-HailoInferer-setup) | Load the HAR model and collect the output names. |

#### method `infer`

```python
def infer(inputs: dict[str, Path]) -> dict[str, npt.NDArray[np.generic]]
```

Run the model on a single set of input files.

Every file is read according to the input it belongs to: an image is converted, while `.npy` and `.raw` data is loaded as is and
must already be laid out as `CHW`. The result is handed to the runner as a channels-last batch of one, keyed by the name of the
matching HN layer. Whatever the SDK prints to stdout and stderr while inferring is discarded.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `inputs` | `dict[str, Path]` | Path to the image, `.npy` or `.raw` file for every model input, keyed by input name. | required |

Returns

| Type | Description |
| --- | --- |
| `dict[str, npt.NDArray[np.generic]]` | The model outputs, keyed by output name. |

#### method `setup`

```python
def setup()
```

Load the HAR model and collect the output names.

The names are taken from the inverse postprocess map recorded in the model metadata, which only a HAR translated from ONNX
carries, and from the original names of the output layers.

Raises

| Type | Description |
| --- | --- |
| `RuntimeError` | If the model carries no original metadata. |
| `NotImplementedError` | If the inverse postprocess map holds more than one entry. |
