# inferer

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

Inference with an RVC4 model through SNPE.

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 RVC4 platform: the inputs are written out as raw files and pushed through the
converted DLC model with `snpe-net-run`. It only works inside the RVC4 Docker image, where the SNPE SDK is installed.

## Classes

### RVC4Inferer

Inferer for RVC4 DLC models based on `snpe-net-run`.

#### Methods

##### infer

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

Run the model on a single set of input images.

Every image is read as `float32` and dumped to a raw file referenced from the SNPE input list, `snpe-net-run` is then invoked on
the DLC model, and the raw files it produces are read back and reshaped to the configured output shapes. SNPE's four-dimensional
output data is channels-last. Its dimensions are recovered from the configured output layout and exposed as `NCHW`.

Parameters

 * `inputs` (`dict[str, Path]`): Path to the image 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):
```

Set paths and cache metadata used by every inference.

The header names the outputs SNPE is asked to write out. Output layouts are captured once alongside the shapes and data types
populated by `Inferer.from_config`.
