()
| 126 | |
| 127 | |
| 128 | def main() -> None: |
| 129 | args = parse_args() |
| 130 | meta_json = args.meta_json.expanduser().resolve() |
| 131 | output_json = args.output_json.expanduser().resolve() |
| 132 | output_dir = args.output_dir.expanduser().resolve() |
| 133 | smplx_model_dir = args.smplx_model_dir.expanduser().resolve() |
| 134 | repo_root = find_repo_root(meta_json) |
| 135 | |
| 136 | entries = json.loads(meta_json.read_text()) |
| 137 | if not isinstance(entries, list): |
| 138 | raise ValueError(f"Expected a list in {meta_json}, got {type(entries).__name__}") |
| 139 | |
| 140 | updated_entries: List[Dict[str, Any]] = [] |
| 141 | to_process = entries if args.limit is None else entries[: args.limit] |
| 142 | |
| 143 | for entry in tqdm(to_process, desc="Render MBench videos"): |
| 144 | motion_path = entry.get("motion_path") |
| 145 | if not motion_path: |
| 146 | updated_entries.append(entry) |
| 147 | continue |
| 148 | motion_file = resolve_repo_path(meta_json, str(motion_path)) |
| 149 | # Use global_id to ensure unique file names across dimensions |
| 150 | motion_id = entry.get("global_id", entry.get("id", Path(motion_file).stem)) |
| 151 | outputs = render_single_motion( |
| 152 | motion_file, |
| 153 | motion_id, |
| 154 | output_dir, |
| 155 | smplx_model_dir, |
| 156 | args.device, |
| 157 | fps=args.fps, |
| 158 | width=args.width, |
| 159 | height=args.height, |
| 160 | ) |
| 161 | updated_entry = update_entry_paths(entry, repo_root, Path(outputs["pt"]), Path(outputs["mp4"])) |
| 162 | updated_entries.append(updated_entry) |
| 163 | |
| 164 | # Preserve any remaining entries if limit was used |
| 165 | if args.limit is not None and len(entries) > args.limit: |
| 166 | updated_entries.extend(entries[args.limit :]) |
| 167 | |
| 168 | output_json.parent.mkdir(parents=True, exist_ok=True) |
| 169 | output_json.write_text(json.dumps(updated_entries, indent=2)) |
| 170 | print(f"Rendered videos/PT caches to {output_dir}") |
| 171 | print(f"Wrote updated meta JSON with video_path/mbench_eval_path to {output_json}") |
| 172 | |
| 173 | |
| 174 | if __name__ == "__main__": |
no test coverage detected