# getters

Python API: `modelconverter.platforms.getters`

Factories for the platform-specific conversion components.

Every conversion platform (RVC2, RVC3, RVC4 and Hailo) provides its own exporter and inferer; the benchmark is missing for Hailo,
and the analyzer and the visualizer are provided by RVC4 only. The getters in this module map a
[Platform](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/utils/types.md#types-Classes-Platform)
to the matching implementation and import it lazily, so that only the dependencies of the selected component need to be available.
The exporter and inferer dependencies live in the platform's Docker image; the host-run benchmark, analyzer and visualizer take
theirs from the host environment.

## Functions

| Name | Description |
| --- | --- |
| [`get_analyzer`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/getters.md#getters-Functions-get_analyzer) | Create the [Analyzer](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/base_analyze.md#base_analyze-Classes-Analyzer) implementation for the given platform. |
| [`get_benchmark`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/getters.md#getters-Functions-get_benchmark) | Create the [Benchmark](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/base_benchmark.md#base_benchmark-Classes-Benchmark) implementation for the given platform. |
| [`get_exporter`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/getters.md#getters-Functions-get_exporter) | Create the [Exporter](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/base_exporter.md#base_exporter-Classes-Exporter) implementation for the given platform. |
| [`get_inferer`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/getters.md#getters-Functions-get_inferer) | Create 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 for the given platform. |
| [`get_visualizer`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/getters.md#getters-Functions-get_visualizer) | Create the [Visualizer](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/base_visualize.md#base_visualize-Classes-Visualizer) implementation for the given platform. |

### function `get_analyzer`

```python
def get_analyzer(
    platform: Platform,
    device_ip: str | None,
    device_id: str | None,
    dlc_model_path: str,
    image_dirs: dict[str, str],
    *,
    image_subset: int | None = None,
) -> Analyzer
```

Create the
[Analyzer](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/base_analyze.md#base_analyze-Classes-Analyzer)
implementation for the given platform.

Only RVC4 provides an analyzer.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `platform` | `Platform` | Platform the model was converted for. | required |
| `device_ip` | `str | None` | IP address of the device to analyze on. | required |
| `device_id` | `str | None` | ID of the device to analyze on. | required |
| `dlc_model_path` | `str` | Path or URL of the DLC model to analyze. | required |
| `image_dirs` | `dict[str, str]` | Mapping of the model's input names to the directories holding the data for that input. | required |
| `image_subset` | `int | None` | If given, only the first `image_subset` supported files of every directory are used. | `None` |

Returns

| Type | Description |
| --- | --- |
| `Analyzer` | Analyzer for the given platform. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If `platform` is not `Platform.RVC4`. |

### function `get_benchmark`

```python
def get_benchmark(platform: Platform, model_path: str) -> Benchmark
```

Create the
[Benchmark](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/base_benchmark.md#base_benchmark-Classes-Benchmark)
implementation for the given platform.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `platform` | `Platform` | Platform to benchmark the model on. | required |
| `model_path` | `str` | Model to benchmark. | required |

Returns

| Type | Description |
| --- | --- |
| `Benchmark` | Benchmark for the given platform. |

Raises

| Type | Description |
| --- | --- |
| `NotImplementedError` | If `platform` is `Platform.HAILO`. |

### function `get_exporter`

```python
def get_exporter(
    platform: Platform,
    config: SingleStageConfig,
    output_dir: Path,
) -> Exporter
```

Create the
[Exporter](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/base_exporter.md#base_exporter-Classes-Exporter)
implementation for the given platform.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `platform` | `Platform` | Platform the model is converted for. | required |
| `config` | `SingleStageConfig` | Configuration of the stage to convert. | required |
| `output_dir` | `Path` | Directory the converted model is written to. | required |

Returns

| Type | Description |
| --- | --- |
| `Exporter` | Exporter for the given platform. |

### function `get_inferer`

```python
def get_inferer(
    platform: Platform,
    model_path: str,
    src: Path,
    dest: Path,
    config: SingleStageConfig,
) -> Inferer
```

Create 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 for the given platform.

The inferer is constructed using its `from_config` constructor.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `platform` | `Platform` | Platform the model was converted for. | required |
| `model_path` | `str` | Path to the converted model. | required |
| `src` | `Path` | Directory holding the input files. | required |
| `dest` | `Path` | Directory the outputs are written to. | required |
| `config` | `SingleStageConfig` | Configuration of the stage to run. | required |

Returns

| Type | Description |
| --- | --- |
| `Inferer` | Inferer for the given platform. |

### function `get_visualizer`

```python
def get_visualizer(platform: Platform, dir_path: str | None = None) -> Visualizer
```

Create the
[Visualizer](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/platforms/base_visualize.md#base_visualize-Classes-Visualizer)
implementation for the given platform.

Only RVC4 provides a visualizer.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `platform` | `Platform` | Platform the model was converted for. | required |
| `dir_path` | `str | None` | Directory containing the analysis results. Defaults to the `analysis` subdirectory of the modelconverter output directory. | `None` |

Returns

| Type | Description |
| --- | --- |
| `Visualizer` | Visualizer for the given platform. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If `platform` is not `Platform.RVC4`. |
