archive_utils
最后更新
luxonis_train.core.utils.archive_utils导出模型及其头部的 NN 存档条目。LuxonisModel.archive 使用这些函数构建存档配置的 inputs、outputs 和 heads。LuxonisModel.export 还读取 modelconverter 配置的输入和输出,该配置写入 ONNX 文件旁边。类
ArchiveMetadataDict
属性
dtype
int8、int32、uint8、float32 和 float16 之一。shape
0。函数
get_head_configs
Python
1def get_head_configs(lightning_module: LuxonisLightningModule, outputs: list[dict]) -> list[dict]:heads 条目。该函数按构建顺序访问 lightning_module 的节点。它跳过不是 BaseHead 的节点,以及设置了 remove_on_export 的头部。对于每个其他头部,它从 BaseHead.get_head_config 开始,并添加两个键:"name":节点的名称。当较早的头部已经使用了该名称时,该函数会附加_<n>,其中<n>是到目前为止已使用的名称数量。"outputs":头部的 BaseNode.export_output_names。当它们为None或为空时,该函数会选择outputs中属于节点名称的名称。
lightning_module(LuxonisLightningModule):存档描述其头部的模块。outputs(list[dict]):NN 存档配置的输出,每个都有一个"name"键。
list[dict]:每个导出头部的配置字典,包含键"parser"、"metadata"、"name"和"outputs"。
get_inputs
Python
1def get_inputs(path: Path) -> dict[str, ArchiveMetadataDict]:graph.input 的每个条目。参数path(Path):模型文件,后缀为.onnx。
dict[str, ArchiveMetadataDict]:每个输入的形状和数据类型,以输入名称为键,按图顺序排列。
NotImplementedError:当path的后缀不是.onnx时。ValueError:当文件无法作为 ONNX 模型加载,或者输入具有不支持的数据类型时。
get_outputs
Python
1def get_outputs(path: Path) -> dict[str, ArchiveMetadataDict]:graph.output 的每个条目。参数path(Path):模型文件,后缀为.onnx。
dict[str, ArchiveMetadataDict]:每个输出的形状和数据类型,以输出名称为键,按图顺序排列。
NotImplementedError:当path的后缀不是.onnx时。ValueError:当文件无法作为 ONNX 模型加载,或者输出具有不支持的数据类型时。