yunet
最后更新
depthai_nodes.node.parsers.yunet类
YuNetParser
Note
发出
dai.ImgDetections 消息。dai.ImgDetections 消息包含检测到的人脸的边界框、标签、置信度分数和关键点。方法
init
Python
1def __init__(conf_threshold: float = 0.8, iou_threshold: float = 0.3, max_det: int = 5000, input_size: tuple[int, int] = None, loc_output_layer_name: str = None, conf_output_layer_name: str = None, iou_output_layer_name: str = None):conf_threshold(float): 检测到人脸的置信度分数阈值。iou_threshold(float): 非极大值抑制阈值。max_det(int): 要保留的最大检测数量。input_size(tuple[int, int]): 模型的输入大小(宽度,高度)。loc_output_layer_name(str): 位置预测的输出层名称。conf_output_layer_name(str): 置信度预测的输出层名称。iou_output_layer_name(str): IoU 预测的输出层名称。
build
Python
1def build(head_config: dict[str, Any]) -> YuNetParser:head_config(dict[str, Any]): 解析器的头部配置。
YuNetParser: 设置了头部配置的解析器对象。
compute
Python
1def compute(*, input_size: tuple[int, int], loc: np.ndarray, conf: np.ndarray, iou: np.ndarray, conf_threshold: float, iou_threshold: float, max_det: int, anchors: np.ndarray, label_names: list[str] | None = None, nms_fn: Callable[..., np.ndarray], top_left_wh_to_xywh_fn: Callable[[np.ndarray], np.ndarray]) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, list[str] | None]:Note
使用 depthai_nodes.node.parsers.utils.yunet.compute_yunet_detections;有关张量布局和验证详细信息,请参阅该帮助程序。
input_size(tuple[int, int]): 模型输入大小,格式为(width, height)。loc(np.ndarray): 每个锚框和五个关键点的偏移量。conf(np.ndarray): 每个锚框的类别置信度张量。iou(np.ndarray): 每个锚框的 IoU 置信度张量。conf_threshold(float): 用于过滤候选的最小检测置信度。iou_threshold(float): 用于非极大值抑制的交并比阈值。max_det(int): 在抑制期间要保留或考虑的最大检测候选数量。anchors(np.ndarray): 用于解码模型预测的预计算锚点坐标。label_names(list[str] | None): 可选的类名查找,按预测的类 ID 索引。nms_fn(Callable[..., np.ndarray]): 抑制可调用对象,接受框、分数、置信度/IoU 阈值和max_det;返回保留的索引。top_left_wh_to_xywh_fn(Callable[[np.ndarray], np.ndarray]): 将左上角 XY/宽度/高度框转换为中心 XY/宽度/高度的可调用对象。
tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, list[str] | None]: 归一化的中心 XY/宽度/高度框、每个面部的五个归一化 XY 关键点、分数、零值类别 ID 和可选的类别名称。没有候选时返回空数组。
emit
Python
1def emit(output: dai.NNData, bboxes: np.ndarray, keypoints: np.ndarray, scores: np.ndarray, labels: np.ndarray, label_names: list[str] | None):dai.ImgDetections 消息并将其发送到 out。复制源时间戳和序列号,并在存在时携带源图像变换。参数output(dai.NNData): 携带张量和源时间戳、序列号以及可选图像变换的神经网络输出。bboxes(np.ndarray):compute()返回的归一化中心 XY/宽度/高度框。keypoints(np.ndarray):compute()返回的归一化关键点坐标。scores(np.ndarray): 与计算负载对应的置信度分数。labels(np.ndarray): 与框对应的整数类别 ID。label_names(list[str] | None): 与检测对应的可选类别名称。
extract
Python
1def extract(output: dai.NNData) -> tuple[np.ndarray, np.ndarray, np.ndarray]:output(dai.NNData): 携带张量和源时间戳、序列号以及可选图像变换的神经网络输出。
tuple[np.ndarray, np.ndarray, np.ndarray]: 定位、类别置信度和 IoU 张量,按此顺序。缺少配置的名称将从唯一的loc、conf和iou前缀推断。
ValueError: 如果配置的层不存在或推断的层前缀缺失或模糊。
run
Python
1def run(self):setInputSize
Python
1def setInputSize(input_size: tuple[int, int]):input_size(tuple[int, int]): 模型的输入大小(宽度,高度)。
setOutputLayerConf
Python
1def setOutputLayerConf(conf_output_layer_name: str):conf_output_layer_name(str): 置信度张量的输出层名称。
setOutputLayerIou
Python
1def setOutputLayerIou(iou_output_layer_name: str):iou_output_layer_name(str): IoU 张量的输出层名称。
setOutputLayerLoc
Python
1def setOutputLayerLoc(loc_output_layer_name: str):loc_output_layer_name(str): 位置张量的输出层名称。