dummy_loader
最后更新
luxonis_train.loaders.dummy_loader一个生成零样本的加载器,用于在没有数据集的情况下运行。类
DummyLoader
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):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。