package documentation

Public entry point for Luxonis NN Archive creation and inspection.

The luxonis_ml.nn_archive package collects the schema models and helper functions used to create NN Archive tar files. An archive stores config.json alongside compiled model executables so model metadata, input/output definitions, tensor layouts, and parser-head configuration can travel with the executable artifact.

Example

Build a validated archive with the package-level imports.

from luxonis_ml.nn_archive import ArchiveGenerator

generator = ArchiveGenerator(
    archive_name="model",
    save_path="artifacts",
    cfg_dict=config,
    executables_paths=["model.blob"],
)
archive_path = generator.make_archive()

See Also

luxonis_ml.nn_archive.config_building_blocks for the input, output, metadata, and parser-head schemas used by Model.

Module archive_generator Undocumented
Module config Undocumented
Package config_building_blocks Undocumented
Module model Undocumented
Module utils Undocumented
Module __main__ No module docstring; 0/1 variable, 2/2 functions documented

From __init__.py:

Class ArchiveGenerator Build NN Archive files from configuration and model executables.
Class Config Configuration schema for an NN Archive.
Class Model Configuration for one model stage in an NN Archive.
Function infer_layout Infer a layout code for a tensor shape.
Function is_nn_archive Check whether a path points to a valid NN Archive.
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

>>> 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
strLayout code matching the number of dimensions in shape.
Raises
ValueErrorIf the shape has too many dimensions for automatic layout inference.
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:PathTypePath to the file to check.
Returns
boolTrue if the file is a valid NN Archive, otherwise False.