| 160 | |
| 161 | |
| 162 | class DWPosePipeline: |
| 163 | def __init__(self, det_checkpoint_path: str, pose2d_checkpoint_path: str, device: str = "cuda"): |
| 164 | self.detector = DWposeONNX( |
| 165 | det_onnx_path=det_checkpoint_path, |
| 166 | pose_onnx_path=pose2d_checkpoint_path, |
| 167 | device=device, |
| 168 | ) |
| 169 | self.device = device |
| 170 | logger.info(f"DWPose-ONNX initialized on {device}") |
| 171 | |
| 172 | def __call__( |
| 173 | self, |
| 174 | frames_rgb: List[np.ndarray], |
| 175 | include_hands: bool = False, |
| 176 | include_face: bool = False, |
| 177 | bg_mode: str = "black", |
| 178 | ) -> List[np.ndarray]: |
| 179 | out = [] |
| 180 | for idx, frame in enumerate(frames_rgb): |
| 181 | skeleton = self.detector( |
| 182 | frame, |
| 183 | include_hands=include_hands, |
| 184 | include_face=include_face, |
| 185 | bg_mode=bg_mode, |
| 186 | ) |
| 187 | if skeleton.shape[:2] != frame.shape[:2]: |
| 188 | skeleton = cv2.resize(skeleton, (frame.shape[1], frame.shape[0]), interpolation=cv2.INTER_NEAREST) |
| 189 | out.append(skeleton) |
| 190 | |
| 191 | if (idx + 1) % 50 == 0: |
| 192 | logger.info(f"DWPose: {idx + 1}/{len(frames_rgb)} frames") |
| 193 | return out |
| 194 | |
| 195 | |
| 196 | def run_canny_edges( |
no outgoing calls
no test coverage detected