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

本页目录

  • 函数
  • find_duplicates
  • get_class_distributions
  • get_duplicates_info
  • get_heatmaps
  • get_missing_annotations
  • infer_task
  • merge_uuids
  • rgb_to_bool_masks
  • warn_on_duplicates
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包
最后更新
Python API: luxonis_ml.data.utils.data_utils

函数

find_duplicates

Python
1def find_duplicates(df: pl.LazyFrame) -> dict[str, list[dict[str, Any]]]:
收集重复的 UUID 和注释信息。参数
  • df (pl.LazyFrame): 数据集信息。
返回
  • 字典,包含:
    • "duplicate_uuids": 包含重复的 "uuid" 及其所有关联的 "files" 的字典列表。
    • "duplicate_annotations": 包含 "file_name"、"task_type"、"task_name"、序列化的 "annotation"(分割任务为 "<binary mask>")和重复的 "count" 的字典列表。

get_class_distributions

Python
1def get_class_distributions(df: pl.LazyFrame) -> dict[str, dict[str, list[dict[str, Any]]]]:
返回非分类任务的类别分布信息。参数
  • df (pl.LazyFrame): 数据集信息。
返回
  • dict[str, dict[str, list[dict[str, Any]]]]: 按任务名称和任务类型分组的类别计数。

get_duplicates_info

Python
1def get_duplicates_info(df: pl.LazyFrame) -> dict[str, Any]:
返回重复的 UUID 和注释信息。参数
  • df (pl.LazyFrame): 数据集信息。
返回
  • 包含重复 UUID 和注释详细信息的字典:
    • "duplicate_uuids": {"uuid": str, "files": list[str]} 条目列表。
    • "duplicate_annotations": 包含 "file_name"、"task_name"、"task_type"、"annotation" 和 "count" 的条目列表。

get_heatmaps

Python
1def get_heatmaps(df: pl.LazyFrame, sample_size: int | None = None, downsample_factor: int = 5) -> dict[str, dict[str, list[list[int]]]]:
为边界框、关键点和分割掩码生成热图。热图在归一化图像坐标上的固定 15×15 网格上累积。边界框贡献其中心点,关键点贡献可见点,分割掩码在可选下采样后贡献前景像素。参数
  • df (pl.LazyFrame): 数据集信息。
  • sample_size (int | None): 用于生成热图的可选样本数量。
  • downsample_factor (int): 用于下采样分割掩码的因子。值为 5 表示保留每第五行和第五列。
返回
  • dict[str, dict[str, list[list[int]]]]: 按任务名称和任务类型分组的热图。每个热图都是一个 15×15 的嵌套计数列表。

get_missing_annotations

Python
1def get_missing_annotations(df: pl.LazyFrame) -> list[str]:
返回没有注释的文件路径。参数
  • df (pl.LazyFrame): 数据集信息。
返回
  • list[str]: 没有注释的文件路径。

infer_task

Python
1def infer_task(old_task: str, class_name: str | None, current_classes: dict[str, dict[str, int]]) -> str:

merge_uuids

Python
1def merge_uuids(uuids: Iterable[str]) -> uuid.UUID:
将多个 UUID 合并为一个确定性 UUID,与顺序无关。参数
  • uuids (Iterable[str]): 要合并的 UUID 字符串。
返回
  • uuid.UUID: 确定性合并 UUID。

rgb_to_bool_masks

Python
1def rgb_to_bool_masks(segmentation_mask: np.ndarray, class_colors: dict[str, RGB], add_background_class: bool = False) -> Iterator[tuple[str, np.ndarray]]:
将 RGB 分割掩码转换为布尔类别掩码。参数
  • segmentation_mask (np.ndarray): RGB 分割掩码,其中每个像素颜色标识其类别。
  • class_colors (dict[str, RGB]): 从类别名称到 RGB 颜色的映射。
  • add_background_class (bool): 是否为不属于任何类别的像素添加 "background" 掩码。背景掩码首先生成。
返回
  • Iterator[tuple[str, np.ndarray]]: 类别名称及其布尔掩码的迭代器。

warn_on_duplicates

Python
1def warn_on_duplicates(df: pl.LazyFrame):
记录重复 UUID 和注释的警告。参数
  • df (pl.LazyFrame): 数据集信息。