()
| 110 | |
| 111 | |
| 112 | def main(): |
| 113 | args = parse_args() |
| 114 | |
| 115 | input_dir = Path(args.input_dir) |
| 116 | output_dir = Path(args.output_dir) |
| 117 | |
| 118 | if not input_dir.exists(): |
| 119 | print(f"Error: Input directory does not exist: {input_dir}") |
| 120 | return |
| 121 | |
| 122 | # Create output directory |
| 123 | output_dir.mkdir(parents=True, exist_ok=True) |
| 124 | |
| 125 | # Find all subdirectories (numbered folders) |
| 126 | subfolders = [f for f in input_dir.iterdir() if f.is_dir()] |
| 127 | |
| 128 | # Sort by numeric value |
| 129 | try: |
| 130 | subfolders.sort(key=lambda x: int(x.name)) |
| 131 | except ValueError: |
| 132 | subfolders.sort() |
| 133 | |
| 134 | print(f"Found {len(subfolders)} result folders in {input_dir}") |
| 135 | |
| 136 | collected_count = 0 |
| 137 | error_count = 0 |
| 138 | |
| 139 | for folder in tqdm(subfolders, desc="Processing motions"): |
| 140 | motion_file = find_motion_file(folder) |
| 141 | |
| 142 | if motion_file is None: |
| 143 | print(f"Warning: No motion file found in {folder}") |
| 144 | error_count += 1 |
| 145 | continue |
| 146 | |
| 147 | try: |
| 148 | # Load motion tensor |
| 149 | motion_tensor = load_motion_tensor(motion_file) |
| 150 | |
| 151 | # Convert to 3D joints with coordinate transformation |
| 152 | joints = convert_motion_to_joints(motion_tensor) |
| 153 | |
| 154 | # Output filename: {folder_id}.pt or .npy |
| 155 | output_filename = f"{folder.name}.npy" |
| 156 | output_path = output_dir / output_filename |
| 157 | |
| 158 | # Save as numpy array (MBench render.py expects (frames, joints, 3)) |
| 159 | np.save(output_path, joints) |
| 160 | |
| 161 | collected_count += 1 |
| 162 | |
| 163 | except Exception as e: |
| 164 | print(f"Error processing {folder.name}: {e}") |
| 165 | error_count += 1 |
| 166 | continue |
| 167 | |
| 168 | print(f"\n=== Summary ===") |
| 169 | print(f"Total folders processed: {len(subfolders)}") |
no test coverage detected