# 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)
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

### HailoInferer

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

#### Methods

##### infer

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

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.

Parameters

 * `inputs` (`dict[str, Path]`): Path to the image, `.npy` or `.raw` file for every model input, keyed by input name.

Returns

 * `dict[str, np.ndarray]`: The model outputs, keyed by output name.

##### setup

```python
def setup(self):
```

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

 * `RuntimeError`: If the model carries no original metadata.
 * `NotImplementedError`: If the inverse postprocess map holds more than one entry.
