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

本页目录

  • 类
  • SCRFDParser
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包
最后更新
Python API: depthai_nodes.node.parsers.scrfd

类

SCRFDParser

用于解析 SCRFD 人脸检测模型输出的解析器类。

方法

init
Python
1def __init__(output_layer_names: list[str] = None, conf_threshold: float = 0.5, iou_threshold: float = 0.5, max_det: int = 100, input_size: tuple[int, int] = (640, 640), feat_stride_fpn: tuple = (8, 16, 32), num_anchors: int = 2):
初始化解析器节点。参数
  • output_layer_names (list[str]): 与解析器相关的输出层的名称。
  • conf_threshold (float): 检测到人脸的置信度分数阈值。
  • iou_threshold (float): 非极大值抑制阈值。
  • max_det (int): 要保留的最大检测数量。
  • input_size (tuple[int, int]): 模型的输入大小。
  • feat_stride_fpn (tuple): 特征步幅列表。
  • num_anchors (int): 锚点数量。
build
Python
1def build(head_config: dict[str, Any]) -> SCRFDParser:
配置解析器。参数
  • head_config (dict[str, Any]): 解析器的头部配置。
返回
  • SCRFDParser: 设置了头部配置的解析器对象。
compute
Python
1def compute(**kwargs):
解码 SCRFD 数组,无需发送消息。参数返回
  • 归一化的中心 XY/宽度/高度框、分数、关键点、零值人脸类别 ID 和可选的映射类别名称。
emit
Python
1def emit(output: dai.NNData, bboxes: np.ndarray, scores: np.ndarray, keypoints: np.ndarray, labels: np.ndarray, label_names: list[str] | None):
创建 dai.ImgDetections 消息并将其发送到 out。复制源时间戳和序列号,并在存在时携带源图像转换。参数
  • output (dai.NNData): 携带张量和源时间戳、序列号以及可选图像转换的神经网络输出。
  • bboxes (np.ndarray): compute() 返回的归一化中心 XY/宽度/高度框。
  • scores (np.ndarray): 与计算出的有效载荷对应的置信度分数。
  • keypoints (np.ndarray): compute() 返回的归一化关键点坐标。
  • labels (np.ndarray): 与框对应的整数类别 ID。
  • label_names (list[str] | None): 与检测对应的可选类别名称。
extract
Python
1def extract(output: dai.NNData) -> tuple[list[np.ndarray], list[np.ndarray], list[np.ndarray]]:
选择并反量化解析所需的模型张量。参数
  • output (dai.NNData): 携带张量和源时间戳、序列号以及可选图像转换的神经网络输出。
返回
  • tuple[list[np.ndarray], list[np.ndarray], list[np.ndarray]]: 按配置的步幅顺序排列的框、分数和关键点张量列表,每个步幅的形状分别为 (N, 4)、(N,) 和 (N, 10)。
引发
  • ValueError: 如果配置的步幅没有分数、框或关键点层。
run
Python
1def run(self):
读取排队的网络输出,解析它们,并在运行时发出结果。管道调用此处理循环。当输入队列关闭或节点停止时,它会退出。
setFeatStrideFPN
Python
1def setFeatStrideFPN(feat_stride_fpn: list[int]):
设置 FPN 的特征步幅。参数
  • feat_stride_fpn (list[int]): FPN 的特征步幅。
setInputSize
Python
1def setInputSize(input_size: tuple[int, int]):
设置模型的输入大小。参数
  • input_size (tuple[int, int]): 模型的输入大小。
setNumAnchors
Python
1def setNumAnchors(num_anchors: int):
设置锚点数量。参数
  • num_anchors (int): 锚点数量。
setOutputLayerNames
Python
1def setOutputLayerNames(output_layer_names: list[str]):
设置解析器的输出层名称。参数
  • output_layer_names (list[str]): 要使用的输出层名称。

属性

conf_threshold
检测到人脸的置信度分数阈值。
feat_stride_fpn
特征步幅元组。
input_size
模型的输入大小。
iou_threshold
非极大值抑制阈值。
label_names
max_det
要保留的最大检测数量。
num_anchors
锚点数量。
output_layer_name
与解析器相关的输出层名称。
output_layer_names