# utils

Python API: `luxonis_ml.nn_archive.utils`

## Functions

### infer_layout

```python
def infer_layout(shape: list[int]) -> str:
```

Infer a layout code for a tensor shape.

The function recognizes common image tensor layouts. For other shapes, it uses the first available letters starting at `C`.

> **Example**
> ```pycon
>>> infer_layout([1, 3, 256, 256])
'NCHW'
>>> infer_layout([256, 256, 3])
'HWC'
>>> infer_layout([1, 19, 7, 8])
'NCDE'
```

Parameters

 * `shape` (`list[int]`): Tensor shape to infer from.

Returns

 * `str`: Layout code matching the number of dimensions in `shape`.

Raises

 * `ValueError`: If the shape has too many dimensions for automatic layout inference.

### is_nn_archive

```python
def is_nn_archive(path: PathType) -> bool:
```

Check whether a path points to a valid NN Archive.

A valid archive must be a tar file and contain a top-level `config.json` member.

Parameters

 * `path` (`PathType`): Path to the file to check.

Returns

 * `bool`: `True` if the file is a valid NN Archive, otherwise `False`.
