# input

Python API: `luxonis_ml.nn_archive.config_building_blocks.base_models.input`

## Classes

| Name | Description |
| --- | --- |
|
[`Input`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/nn_archive/config_building_blocks/base_models/input.md)
| Model input stream definition. |
|
[`PreprocessingBlock`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/nn_archive/config_building_blocks/base_models/input.md)
| Preprocessing operations applied to model input data. |

### class `Input`

```python
class Input(BaseModelExtraForbid)
```

Model input stream definition.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `dtype` | `DataType` | Data type of the input data, such as `"float32"`. |
| `input_type` | `InputType` | Expected kind of input data, such as `"image"`. |
| `layout` | `str` | Letter code for interpreting tensor dimensions, such as `"NCHW"`. |
| `name` | `str` | Name of the input layer. |
| `preprocessing` | `PreprocessingBlock` | Preprocessing applied to the input data. |
| `shape` | `list[int]` | Input tensor shape. |

Methods

| Name | Description |
| --- | --- |
|
[`infer_layout`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/nn_archive/config_building_blocks/base_models/input.md)
| Infer the layout when a shape is provided without one. |
|
[`validate_layout`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/nn_archive/config_building_blocks/base_models/input.md)
| Validate that the layout is compatible with the input shape. |

#### static method `infer_layout`

```python
def infer_layout(data: dict[str, Any]) -> dict[str, Any]
```

Infer the layout when a shape is provided without one.

> **Examples**
> ```pycon
>>> Input.infer_layout({"shape": [1, 3, 224, 224]})["layout"]
'NCHW'
>>> Input.infer_layout({"shape": [1, 3, 16, 16, 2]})
{'shape': [1, 3, 16, 16, 2], 'layout': 'NCDEF'}
>>> "layout" in Input.infer_layout({"shape": [1] * 30})
False
```

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `data` | `dict[str, Any]` | Raw input model data. | required |

Returns

| Type | Description |
| --- | --- |
| `dict[str, Any]` | Raw model data with `layout` added when inference succeeds. |

#### method `validate_layout`

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

Validate that the layout is compatible with the input shape.

The layout must be a one-to-one description of the shape, so |layout| = |shape|. When `N` is present it denotes batch size and must be first. Image inputs must include a channel dimension `C`.

Returns

| Type | Description |
| --- | --- |
| `Self` | The validated input model. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the layout contains duplicate letters, its length does not match the shape length, `N` is present but not first, or image input has no `C` dimension. |

### class `PreprocessingBlock`

```python
class PreprocessingBlock(BaseModelExtraForbid)
```

Preprocessing operations applied to model input data.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `dai_type` | `str | None` | Optional DepthAI input type used to configure pipeline input handling. |
| `interleaved_to_planar` | `bool | None` |  |
| `mean` | `list[float] | None` | Optional mean values in channel order. The order should match the preprocessing used during training. |
| `resize_mode` | `Literal['CROP', 'STRETCH', 'LETTERBOX'] | None` | Optional image resize policy. `CROP` center-crops, `STRETCH` resizes without preserving aspect ratio, and `LETTERBOX` preserves aspect ratio by padding. |
| `reverse_channels` | `bool | None` |  |
| `scale` | `list[float] | None` | Optional standardization values in channel order. The order should match the preprocessing used during training. |
