(
motion_path: Path,
motion_id: str,
output_dir: Path,
smplx_model_dir: Path,
*,
device: str,
fps: int,
width: int,
height: int,
noise_std: float = 0.0,
)
| 195 | |
| 196 | |
| 197 | def convert_and_render( |
| 198 | motion_path: Path, |
| 199 | motion_id: str, |
| 200 | output_dir: Path, |
| 201 | smplx_model_dir: Path, |
| 202 | *, |
| 203 | device: str, |
| 204 | fps: int, |
| 205 | width: int, |
| 206 | height: int, |
| 207 | noise_std: float = 0.0, |
| 208 | ) -> Tuple[Path, Path]: |
| 209 | pt_path = output_dir / f"{motion_id}.pt" |
| 210 | mp4_path = output_dir / f"{motion_id}.mp4" |
| 211 | if pt_path.exists() and mp4_path.exists(): |
| 212 | return pt_path, mp4_path |
| 213 | |
| 214 | motion_tensor = load_motion_tensor(motion_path) |
| 215 | |
| 216 | smplx_model = SMPLX( |
| 217 | model_path=str(smplx_model_dir), |
| 218 | gender="neutral", |
| 219 | use_pca=False, |
| 220 | batch_size=motion_tensor.shape[0], |
| 221 | ).to(device) |
| 222 | smplx_model.eval() |
| 223 | payload = run_smplx(motion_tensor, smplx_model, torch.device(device), noise_std=noise_std) |
| 224 | output_dir.mkdir(parents=True, exist_ok=True) |
| 225 | torch.save(payload, pt_path) |
| 226 | |
| 227 | render_video_from_vertices( |
| 228 | payload["vertices"], |
| 229 | payload["joints"], |
| 230 | getattr(smplx_model, "faces").detach().cpu().numpy() |
| 231 | if torch.is_tensor(getattr(smplx_model, "faces")) |
| 232 | else np.asarray(getattr(smplx_model, "faces")), |
| 233 | mp4_path, |
| 234 | width=width, |
| 235 | height=height, |
| 236 | fps=fps, |
| 237 | ) |
| 238 | return pt_path, mp4_path |
no test coverage detected