# config

Python API: `hubai_sdk.utils.config`

Parse and validate model conversion configuration.

[Config](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) is the root
configuration object used by hosted conversion. It accepts either a compact single-stage mapping or an explicit `stages` mapping.
For model formats with embedded metadata, missing tensor shapes and data types are inferred from the source file.

> **Example**
> A compact YAML configuration can define preprocessing and target options.

```yaml
name: detector
input_model: detector.onnx
inputs:
  - name: images
    shape: [1, 3, 640, 640]
    layout: NCHW
    encoding:
      from: RGB
      to: BGR
    mean_values: imagenet
rvc2:
  number_of_shaves: 8
  superblob: true
```

Top-level tensor shortcuts such as `shape`, `layout`, `mean_values`, and `scale_values` are propagated to inputs that do not
override them. Unknown fields are rejected to catch misspelled options early.

## Classes

| Name | Description |
| --- | --- |
| [`BlobBaseConfig`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) |
Shared OpenVINO Model Optimizer and blob compiler options. |
| [`Config`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) | Root
configuration for a single- or multi-stage model. |
| [`CustomBaseModel`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) |
Base for strict configuration models that reject unknown fields. |
| [`EncodingConfig`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) |
Input channel conversion performed before inference. |
| [`HailoConfig`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) | Hailo
Dataflow Compiler and hardware options. |
| [`InputConfig`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) | Tensor
metadata and preprocessing for one model input. |
| [`OutputConfig`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) | Shape,
layout, and data type of one model output. |
| [`RVC2Config`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) | RVC2
compilation options. |
| [`RVC3Config`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) | RVC3
compilation and POT target options. |
| [`RVC4Config`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) | Qualcomm
SNPE conversion, quantization, and graph options. |
| [`SingleStageConfig`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) |
Configuration for one model in a conversion pipeline. |
| [`TargetConfig`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) |
Options shared by every conversion target. |

### class `BlobBaseConfig`

```python
class BlobBaseConfig(TargetConfig)
```

Shared OpenVINO Model Optimizer and blob compiler options.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `compile_tool_args` | `list[str]` |  |
| `compress_to_fp16` | `bool` |  |
| `mo_args` | `list[str]` |  |

### class `Config`

```python
class Config(LuxonisConfig)
```

Root configuration for a single- or multi-stage model.

A mapping without `stages` is wrapped as a single stage automatically. Shared keys placed beside `stages` are copied into each
stage unless the stage supplies its own value.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `name` | `str` | Pipeline name. Derived from stage names when omitted. |
| `rich_logging` | `bool` | Whether conversion tools should use rich terminal logs. |
| `stages` | `dict[str, SingleStageConfig]` | Stage configurations keyed by stage name. |

Methods

| Name | Description |
| --- | --- |
| [`get_stage_config`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) |
Return a stage config, inferring it for single-stage models. |

#### method `get_stage_config`

```python
def get_stage_config(stage: str | None) -> SingleStageConfig
```

Return a stage config, inferring it for single-stage models.

### class `CustomBaseModel`

```python
class CustomBaseModel(BaseModel)
```

Base for strict configuration models that reject unknown fields.

Attributes

| Name | Description |
| --- | --- |
| `model_config` |  |

### class `EncodingConfig`

```python
class EncodingConfig(CustomBaseModel)
```

Input channel conversion performed before inference.

`from_` is the encoding supplied by the application and `to` is the encoding expected by the model. The input field and serialized
field name for `from_` is `"from"`.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `from_` | `Encoding` |  |

### class `HailoConfig`

```python
class HailoConfig(TargetConfig)
```

Hailo Dataflow Compiler and hardware options.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `alls` | `list[str]` |  |
| `batch_size` | `int` |  |
| `compression_level` | `Literal[0, 1, 2, 3, 4, 5]` |  |
| `disable_compilation` | `bool` |  |
| `hw_arch` | `Literal['hailo8', 'hailo8l', 'hailo8r', 'hailo10h', 'hailo15h', 'hailo15m']` |  |
| `optimization_level` | `Literal[-100, 0, 1, 2, 3, 4]` |  |

### class `InputConfig`

```python
class InputConfig(OutputConfig)
```

Tensor metadata and preprocessing for one model input.

Scalar mean and scale values are expanded to three channels. The named value `"imagenet"` expands to the standard ImageNet
preprocessing vectors. One-channel inputs are normalized to grayscale encoding.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `encoding` | `EncodingConfig` | Source and destination channel ordering. |
| `frozen_value` | `Any | None` | Constant value for an input that is not supplied at run time. |
| `mean_values` | `Annotated[list[float], Field(min_length=1)] | None` | Per-channel value subtracted during preprocessing. |
| `scale_values` | `Annotated[list[float], Field(min_length=1)] | None` | Per-channel divisor applied during preprocessing. |

Properties

| Name | Type | Description |
| --- | --- | --- |
| [`encoding_mismatch`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) |
`bool` | |
| [`is_color_input`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) |
`bool` | |

#### property `encoding_mismatch`

```python
encoding_mismatch: bool
```

#### property `is_color_input`

```python
is_color_input: bool
```

### class `OutputConfig`

```python
class OutputConfig(CustomBaseModel)
```

Shape, layout, and data type of one model output.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `data_type` | `DataType` | Tensor element type. |
| `layout` | `str | None` | Dimension labels such as `"NCHW"`. A default is inferred from `shape` when omitted. |
| `name` | `str` | Tensor name in the source model. |
| `shape` | `list[int] | None` | Tensor dimensions. May be omitted when they can be inferred. |

Methods

| Name | Description |
| --- | --- |
| [`validate_layout`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) |  |

#### method `validate_layout`

```python
def validate_layout() -> Self
```

### class `RVC2Config`

```python
class RVC2Config(BlobBaseConfig)
```

RVC2 compilation options.

A superblob always uses eight SHAVE cores; validation changes `number_of_shaves` to `8` when necessary.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `n_workers` | `PositiveInt | None` |  |
| `number_of_shaves` | `int` |  |
| `superblob` | `bool` |  |

### class `RVC3Config`

```python
class RVC3Config(BlobBaseConfig)
```

RVC3 compilation and POT target options.

### class `RVC4Config`

```python
class RVC4Config(TargetConfig)
```

Qualcomm SNPE conversion, quantization, and graph options.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `compress_to_fp16` | `bool` |  |
| `disable_calibration` | `bool` |  |
| `htp_socs` | `list[Literal['sm8350', 'sm8450', 'sm8550', 'sm8650', 'qcs6490', 'qcs8550']]` |  |
| `keep_raw_images` | `bool` |  |
| `optimization_level` | `Literal[1, 2, 3]` |  |
| `snpe_dlc_graph_prepare_args` | `list[str]` |  |
| `snpe_dlc_quant_args` | `list[str]` |  |
| `snpe_onnx_to_dlc_args` | `list[str]` |  |
| `use_per_channel_quantization` | `bool` |  |
| `use_per_row_quantization` | `bool` |  |

### class `SingleStageConfig`

```python
class SingleStageConfig(CustomBaseModel)
```

Configuration for one model in a conversion pipeline.

Inputs and outputs are inferred from ONNX, OpenVINO IR, and TFLite models when omitted. PyTorch inputs are supported for YOLO
models and use the configured `yolo_input_shape`.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `disable_onnx_optimization` | `bool` |  |
| `disable_onnx_simplification` | `bool` |  |
| `hailo` | `HailoConfig` | Hailo-specific settings. |
| `input_bin` | `Path | None` | Weights file paired with an OpenVINO XML graph. |
| `input_file_type` | `InputFileType` |  |
| `input_model` | `Path` | Local or remote path to the source model. |
| `inputs` | `list[InputConfig]` | Input tensor definitions and preprocessing. |
| `intermediate_outputs_remote_url` | `str | None` |  |
| `keep_intermediate_outputs` | `bool` |  |
| `output_remote_url` | `str | None` |  |
| `outputs` | `list[OutputConfig]` | Output tensor definitions. |
| `put_file_plugin` | `str | None` |  |
| `rvc2` | `RVC2Config` | RVC2-specific settings. |
| `rvc3` | `RVC3Config` | RVC3-specific settings. |
| `rvc4` | `RVC4Config` | RVC4-specific settings. |

Methods

| Name | Description |
| --- | --- |
| [`get_target_config`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) |
Returns the target configuration for the given target. |

#### method `get_target_config`

```python
def get_target_config(target: Target) -> TargetConfig
```

Returns the target configuration for the given target.

### class `TargetConfig`

```python
class TargetConfig(CustomBaseModel)
```

Options shared by every conversion target.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `disable_calibration` | `bool` |  |

## Module Attributes

| Name | Type | Description |
| --- | --- | --- |
| [`NAMED_VALUES`](https://docs.luxonis.com/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/config.md) |
`dict[str, dict]` | |

### constant `NAMED_VALUES`

```python
NAMED_VALUES: dict[str, dict] = {
    'imagenet': {'mean': [123.675, 116.28, 103.53], 'scale': [58.395, 57.12, 57.375]},
}
```
