Estimate 2D keypoints from image frames and return in H36M format. Parameters ---------- frames : ndarray BGR image frames, shape ``(N, H, W, C)``. Returns ------- keypoints : ndarray H36M-format 2D keypoints, shape ``(num_per
(
self, frames: np.ndarray
)
| 81 | self._model.setup() |
| 82 | |
| 83 | def predict( |
| 84 | self, frames: np.ndarray |
| 85 | ) -> Tuple[np.ndarray, np.ndarray, np.ndarray]: |
| 86 | """Estimate 2D keypoints from image frames and return in H36M format. |
| 87 | |
| 88 | Parameters |
| 89 | ---------- |
| 90 | frames : ndarray |
| 91 | BGR image frames, shape ``(N, H, W, C)``. |
| 92 | |
| 93 | Returns |
| 94 | ------- |
| 95 | keypoints : ndarray |
| 96 | H36M-format 2D keypoints, shape ``(num_persons, N, 17, 2)``. |
| 97 | scores : ndarray |
| 98 | Per-joint confidence scores, shape ``(num_persons, N, 17)``. |
| 99 | valid_frames_mask : ndarray |
| 100 | Boolean mask indicating which frames contain at least one |
| 101 | valid detection, shape ``(N,)``. |
| 102 | """ |
| 103 | from fmpose3d.lib.preprocess import h36m_coco_format, revise_kpts |
| 104 | |
| 105 | self.setup_runtime() |
| 106 | |
| 107 | keypoints, scores = self._model.predict(frames) |
| 108 | |
| 109 | keypoints, scores, valid_frames = h36m_coco_format(keypoints, scores) |
| 110 | keypoints, scores = self._validate_predictions( |
| 111 | keypoints, scores, num_frames=frames.shape[0], |
| 112 | ) |
| 113 | valid_frames_mask = self._compute_valid_frames_mask(keypoints, scores) |
| 114 | |
| 115 | # NOTE: revise_kpts is computed for consistency but is NOT applied |
| 116 | # to the returned keypoints, matching the demo script behaviour. |
| 117 | _revised = revise_kpts(keypoints, scores, valid_frames) # noqa: F841 |
| 118 | return keypoints, scores, valid_frames_mask |
| 119 | |
| 120 | def _validate_predictions( |
| 121 | self, |
no test coverage detected