ml.postprocessing.mediapipe --- Google Mediapipe¶
ml.postprocessing.mediapipe 模块包含用于 Google Mediapipe 模型的后处理器。
class mediapipe_detection_postprocess -- 通用 Mediapipe 检测器¶
BlazeFace 和 BlazePalm 共享的基类。解码基于锚框的边界框和关键点,然后执行 NMS。
- class ml.postprocessing.mediapipe.mediapipe_detection_postprocess(threshold: float = 0.6, anchors: ndarray | None = None, anchor_grid: list[tuple[int, int]] | None = None, scores: list[int] = [], cords: list[int] = [], nms_threshold: float = 0.1, nms_sigma: float = 0.1)¶
创建一个通用 Mediapipe 检测后处理器。
threshold在 sigmoid 之前应用于原始 logits 的分数阈值。anchors可选的预构建锚框数组,形状为(N, 2),包含归一化到[0, 1]的(cx, cy)中心点。若为None,则从anchor_grid生成锚框。anchor_grid当anchors为None时用于生成锚框的(grid_size, scales)元组列表。scores包含分数张量的模型输出索引列表。cords包含边界框/关键点张量的模型输出索引列表。nms_threshold用于非极大值抑制的 IoU 阈值。nms_sigma用于 soft-NMS 分数衰减的 Sigma 值。
class BlazeFace -- 人脸检测¶
对 BlazeFace 模型输出进行后处理。
- class ml.postprocessing.mediapipe.BlazeFace(threshold: float = 0.6, anchors: ndarray | None = None, nms_threshold: float = 0.1, nms_sigma: float = 0.1)¶
创建一个 BlazeFace 后处理器。使用
[(16, 2), (8, 6)]的锚框网格,分数输出为[1, 2],边界框输出为[0, 3]。threshold用于检测的分数阈值。anchors可选的预构建锚框数组;若为None则自动生成。nms_threshold用于非极大值抑制的 IoU 阈值。nms_sigma用于 soft-NMS 分数衰减的 Sigma 值。从
__call__返回一个((x, y, w, h), score, keypoints)元组列表,其中keypoints是一个(x, y)点的列表。
class BlazePalm -- 手掌检测¶
对 BlazePalm 模型输出进行后处理。
- class ml.postprocessing.mediapipe.BlazePalm(threshold: float = 0.6, anchors: ndarray | None = None, nms_threshold: float = 0.1, nms_sigma: float = 0.1)¶
创建一个 BlazePalm 后处理器。使用
[(24, 2), (12, 6)]的锚框网格,分数输出为[0],边界框输出为[1]。threshold用于检测的分数阈值。anchors可选的预构建锚框数组;若为None则自动生成。nms_threshold用于非极大值抑制的 IoU 阈值。nms_sigma用于 soft-NMS 分数衰减的 Sigma 值。从
__call__返回一个((x, y, w, h), score, keypoints)元组列表,其中keypoints是一个(x, y)点的列表。
class FaceLandmarks -- 人脸关键点¶
对 FaceLandmarks 模型输出进行后处理。
- class ml.postprocessing.mediapipe.FaceLandmarks(threshold: float = 0.6, nms_threshold: float = 0.1, nms_sigma: float = 0.1)¶
创建一个 FaceLandmarks 后处理器。
threshold用于接受一个检测结果的分数阈值(在 sigmoid 之后)。nms_threshold用于非极大值抑制的 IoU 阈值。nms_sigma用于 soft-NMS 分数衰减的 Sigma 值。从
__call__返回一个((x, y, w, h), score, keypoints)元组列表,其中keypoints是一个(x, y, z)点的列表。
class HandLandmarks -- 手部关键点¶
对 HandLandmarks 模型输出进行后处理。
- class ml.postprocessing.mediapipe.HandLandmarks(threshold: float = 0.6, nms_threshold: float = 0.1, nms_sigma: float = 0.1)¶
创建一个 HandLandmarks 后处理器。
threshold用于接受一个检测结果的分数阈值。nms_threshold用于非极大值抑制的 IoU 阈值。nms_sigma用于 soft-NMS 分数衰减的 Sigma 值。从
__call__返回[[((x, y, w, h), score, keypoints)]],每个左右手类别(左=0,右=1)对应一个内层列表。keypoints是一个(x, y, z)点的列表。空的类别列表会被保留,以使每个列表的索引与类别索引相匹配。
class MoveNet -- 姿态估计¶
对 MoveNet 单姿态模型输出进行后处理。
- class ml.postprocessing.mediapipe.MoveNet(threshold: float = 0.6, nms_threshold: float = 0.1, nms_sigma: float = 0.1)¶
创建一个 MoveNet 后处理器。
threshold逐关键点的置信度阈值;低于此值的关键点会被排除在边界框和平均分数之外。nms_threshold用于非极大值抑制的 IoU 阈值。nms_sigma用于 soft-NMS 分数衰减的 Sigma 值。从
__call__返回一个((x, y, w, h), score, keypoints)元组列表,其中keypoints是一个以输入像素坐标表示的(x, y, score)点的列表。