scrfd
最后更新
depthai_nodes.node.parsers.utils.scrfd函数
compute_anchor_centers
Python
1def compute_anchor_centers(strides: list[int], input_size: tuple[int, int], num_anchors: int) -> dict[int, np.ndarray]:strides(list[int]): 步幅列表。input_size(tuple[int, int]): 输入大小。num_anchors(int): 锚点数量。
dict[int, np.ndarray]: 锚点中心的字典。
compute_scrfd_detections
Python
1def compute_scrfd_detections(*, bboxes_concatenated: list[np.ndarray], scores_concatenated: list[np.ndarray], kps_concatenated: list[np.ndarray], feat_stride_fpn: tuple[int, ...] | list[int], input_size: tuple[int, int], num_anchors: int, score_threshold: float, nms_threshold: float, anchors: dict[int, np.ndarray], label_names: list[str] | None = None) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, list[str] | None]:bboxes_concatenated(list[np.ndarray]): 按特征金字塔步幅排序的边界框距离张量。scores_concatenated(list[np.ndarray]): 按特征金字塔步幅排序的置信度张量。kps_concatenated(list[np.ndarray]): 按特征金字塔步幅排序的关键点偏移张量。feat_stride_fpn(tuple[int, ...] | list[int]): 与张量列表对应的特征金字塔步幅。input_size(tuple[int, int]): 模型输入大小,格式为(width, height)。num_anchors(int): 每个特征图位置的锚点数量。score_threshold(float): 最小人脸置信度。nms_threshold(float): 用于抑制的交并比阈值。anchors(dict[int, np.ndarray]): 从每个特征步幅到其预计算锚点中心的映射。label_names(list[str] | None): 可选的类名查找,按预测的类 ID 索引。
tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, list[str] | None]: 归一化的中心-XY/宽度/高度框、分数、关键点、零值人脸类 ID 和可选的映射类名。
decode_scrfd
Python
1def decode_scrfd(bboxes_concatenated, scores_concatenated, kps_concatenated, feat_stride_fpn, input_size, num_anchors, score_threshold, nms_threshold, anchors):bboxes_concatenated(list[np.ndarray]): 每个尺度的边界框预测列表。scores_concatenated(list[np.ndarray]): 每个尺度的置信度分数预测列表。kps_concatenated(list[np.ndarray]): 每个尺度的关键点预测列表。feat_stride_fpn(list[int]): 每个尺度的特征步幅列表。input_size(tuple[int]): 模型的输入大小。num_anchors(int): 锚点数量。score_threshold(float): 置信度分数阈值。nms_threshold(float): 非极大值抑制阈值。anchors(dict[int, np.ndarray]): 锚点字典。
tuple[np.ndarray, np.ndarray, np.ndarray]:- 检测到的对象的边界框、置信度分数和关键点。
distance2bbox
Python
1def distance2bbox(points, distance, max_shape=None):points(np.ndarray): 形状为 (n, 2),[x, y]。distance(np.ndarray): 从给定点到 4 个边界(左、上、右、下)的距离。max_shape(tuple[int, int]): 图像的形状。
np.ndarray: 解码后的边界框。
distance2kps
Python
1def distance2kps(points, distance, max_shape=None):points(np.ndarray): 形状为 (n, 2),[x, y]。distance(np.ndarray): 从给定点到 4 个边界(左、上、右、下)的距离。max_shape(tuple[int, int]): 图像的形状。
np.ndarray: 解码后的关键点。