scrfd
最后更新
depthai_nodes.node.parsers.scrfd类
SCRFDParser
注意
发出
dai.ImgDetections 消息。dai.ImgDetections 消息包含检测到的人脸的边界框、标签和置信度分数。方法
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):**kwargs: depthai_nodes.node.parsers.utils.scrfd.compute_scrfd_detections 接受的关键字参数。
- 归一化的中心 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]):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]): 要使用的输出层名称。