ml.postprocessing.mediapipe --- Google Mediapipe

ml.postprocessing.mediapipe 模組包含用於 Google Mediapipe 模型的後處理器。

class mediapipe_detection_postprocess -- 通用 Mediapipe 偵測器

BlazeFaceBlazePalm 共用的基底類別。它解碼基於錨框的邊界框與關鍵點,然後執行 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_gridanchorsNone 時,用於產生錨框的 (grid_size, scales) 元組清單。

scores 包含分數張量的模型輸出索引清單。

cords 包含框/關鍵點張量的模型輸出索引清單。

nms_threshold 非極大值抑制的 IoU 閾值。

nms_sigma soft-NMS 分數衰減的 Sigma 值。

__call__(model: ml.Model, inputs: list, outputs: list) list

對模型輸出執行後處理,並回傳一個 ((x, y, w, h), score, keypoints) 元組清單。當沒有任何偵測通過分數閾值時,回傳一個空元組 ()

detection_post_process(ih: int, iw: int, nms: ml.utils.NMS, model: ml.Model, inputs: list, outputs: list, score_idx: int, cords_idx: int, t: float, anchors: ndarray) None

從單一 (score, cords) 輸出對中解碼並加入邊界框,至所提供的 NMS 累加器中。

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) 點清單。