# 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)
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

### Metadata

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

#### Attributes

##### input_dtypes

Data type of each input, keyed by input name.

##### input_shapes

Shape of each input, keyed by input name.

##### output_dtypes

Data type of each output, keyed by output name.

##### output_shapes

Shape of each output, keyed by output name.

## Functions

### 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`.

Parameters

 * `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.

Returns

 * `Metadata`: Metadata of the model's inputs and outputs.

Raises

 * `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.
