# metadata

Python API: `modelconverter.utils.metadata`

Reading of input and output metadata from model files.

Every conversion platform speaks a different model format, so the rest of modelconverter asks for shapes and data types through
the single
[get_metadata](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/utils/metadata.md#metadata-Functions-get_metadata)
entry point, which dispatches on the file suffix: ONNX, OpenVINO IR (RVC2/RVC3), SNPE DLC (RVC4), Hailo HAR and TFLite. The
readers for the platform-specific formats rely on tooling that is only present inside that platform's container, so they are
imported lazily.

## Classes

| Name | Description |
| --- | --- |
| [`Metadata`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/utils/metadata.md#metadata-Classes-Metadata) | Shapes and data types of a model's inputs and outputs. |

### class `Metadata`

```python
class Metadata
```

Shapes and data types of a model's inputs and outputs.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `input_dtypes` | `dict[str, DataType]` | Data type of each input, keyed by input name. |
| `input_shapes` | `dict[str, list[int]]` | Shape of each input, keyed by input name. |
| `output_dtypes` | `dict[str, DataType]` | Data type of each output, keyed by output name. |
| `output_shapes` | `dict[str, list[int]]` | Shape of each output, keyed by output name. |

## Functions

| Name | Description |
| --- | --- |
| [`get_metadata`](https://docs.luxonis.com/software-v3/ai-inference/conversion/rvc-conversion/offline/modelconverter/modelconverter-api-reference/utils/metadata.md#metadata-Functions-get_metadata) | Read the metadata of a model, whatever format it is in. |

### function `get_metadata`

```python
def get_metadata(model_path: Path) -> Metadata
```

Read the metadata of a model, whatever format it is in.

The format is taken from the file suffix: `.onnx`, `.xml` or `.bin` (OpenVINO IR), `.dlc` or `.csv` (SNPE), `.hef` or `.har`
(Hailo), and `.tflite`.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `model_path` | `Path` | Path to the model file. For an IR model either the `.xml` or the `.bin` file may be given, the other one being derived from it. | required |

Returns

| Type | Description |
| --- | --- |
| `Metadata` | Metadata of the model's inputs and outputs. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the suffix is not one of the supported formats, or if an ONNX or IR model cannot be read. The other formats let their reader's own errors propagate, such as `FileNotFoundError` for a missing file. |
