此页面由 AI 自动翻译。查看英文原版
最后更新

本页目录

  • 类
  • DummyLoader
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包

dummy_loader

最后更新
Python API: luxonis_train.loaders.dummy_loader一个生成零样本的加载器,用于在没有数据集的情况下运行。

类

DummyLoader

一个生成零样本的加载器。LuxonisModel 在 allow_empty_dataset 设置为 true 且加载器构建失败时,会使用它代替配置中的加载器。样本具有模型节点任务所需的标签,因此模型可以在没有数据的情况下构建。get_label_shapes 为 Luxonis 数据格式的每种标签类型提供固定形状。子类可以重写它以提供其他标签的形状。

方法

init
Python
1def __init__(cfg: Config, view: list[str], height: int | None = None, width: int | None = None, image_source: str = 'image', color_space: Literal['RGB', 'BGR', 'GRAY'] = 'RGB', n_keypoints: int = 3, n_classes: int = 1, class_names: list[str] | dict[str, int] | dict[str, dict[str, int]] | None = None, **kwargs):
收集模型的标签和类名。加载器不存储增强,因此 augmentation_config 属性会引发 ValueError。参数
  • cfg (Config): 配置。加载器读取 trainer.batch_size 和 model.nodes 中每个节点的任务。每个任务提供其所需的标签,以节点的 task_name 为键,或者当节点没有 task_name 时以 "" 为键。
  • view (list[str]): 构成视图的拆分。
  • height (int | None): 图像和掩码的高度。如果为 None,则 input_shapes 和 __getitem__ 会引发 ValueError。
  • width (int | None): 图像和掩码的宽度。如果为 None,则 input_shapes 和 __getitem__ 会引发 ValueError。
  • image_source (str): 图像的输入名称。
  • color_space (Literal['RGB', 'BGR', 'GRAY']): 颜色空间。图像对于 "GRAY" 有一个通道,对于其他值有三个通道。
  • n_keypoints (int): 每个任务的关键点数量。
  • n_classes (int): 当 class_names 为 None 时,每个任务的类别数量。
  • class_names (list[str] | dict[str, int] | dict[str, dict[str, int]] | None): 类别。列表根据每个名称的位置给出类别 ID。列表或 dict[str, int] 为每个任务提供相同的类别。dict[str, dict[str, int]] 将每个任务名称映射到其类别。None 为每个任务提供从 "0" 到 str(n_classes - 1) 的名称。
  • **kwargs: 配置的其他加载器参数。加载器会忽略它们。
get_classes
Python
1def get_classes(self) -> dict[str, dict[str, int]]:
返回构造函数构建的类。返回
  • dict[str, dict[str, int]]: 每个任务的类名到类 ID 的映射,以任务名称为键。构造函数的 class_names 参数描述了内容。
get_label_shapes
Python
1def get_label_shapes(labels: dict[str, set[str | Metadata]]) -> dict[str, tuple[int, ...]]:
返回每个标签的零张量的形状。每个标签类型的形状为:
  • boundingbox: [1, 5],一个框。
  • keypoints: [1, 3 * n_keypoints],一个实例。
  • segmentation 和 instance_segmentation: [1, height, width]。
  • 任何其他标签,例如 classification 或 Metadata 标签: [2]。
子类可以重写此方法以提供其他形状。参数
  • labels (dict[str, set[str | Metadata]]): 每个任务所需的标签,以任务名称为键。
返回
  • dict[str, tuple[int, ...]]: 每个标签的形状,以 "<task_name>/<label>" 为键。
get_n_keypoints
Python
1def get_n_keypoints(self) -> dict[str, int] | None:
返回每个任务的 n_keypoints。每个任务都会获得计数,即使是没有关键点标签的任务。返回
  • dict[str, int] | None: n_keypoints,以模型的每个任务名称为键。

属性

input_shapes
图像的形状 [C, H, W],以 image_source 为键。C 对于 "GRAY" 颜色空间是 1,对于其他颜色空间是 3。