Compute the jitter degree of the motion based on the acceleration of the joints.
(full_info_path: str, device: str, **kwargs)
| 125 | } |
| 126 | |
| 127 | def compute_jitter_degree(full_info_path: str, device: str, **kwargs): |
| 128 | """ |
| 129 | Compute the jitter degree of the motion based on the acceleration of the joints. |
| 130 | """ |
| 131 | prompt_dict_ls = load_dimension_info(full_info_path, dimension='Jitter_Degree') |
| 132 | |
| 133 | jitter_degree_list = [] |
| 134 | per_motion_metrics = [] |
| 135 | |
| 136 | for prompt_dict in tqdm(prompt_dict_ls): |
| 137 | evaluation_file = prompt_dict["evaluation_file"] |
| 138 | pred_joints = load_joints(evaluation_file, device) |
| 139 | |
| 140 | # Global jitter degree |
| 141 | velocity = pred_joints[1:] - pred_joints[:-1] # Shape: (T-1, 24, 3) |
| 142 | acceleration = velocity[1:] - velocity[:-1] # Shape: (T-2, 24, 3) |
| 143 | acceleration_magnitude = torch.norm(acceleration, dim=2) # Shape: (T-2, 24) |
| 144 | global_jitter = acceleration_magnitude.mean() |
| 145 | |
| 146 | # Local jitter degree (remove global translation) |
| 147 | local_joints = remove_global_translation(pred_joints) |
| 148 | local_velocity = local_joints[1:] - local_joints[:-1] # Shape: (T-1, 24, 3) |
| 149 | local_acceleration = local_velocity[1:] - local_velocity[:-1] # Shape: (T-2, 24, 3) |
| 150 | local_acceleration_magnitude = torch.norm(local_acceleration, dim=2) # Shape: (T-2, 24) |
| 151 | local_jitter = local_acceleration_magnitude.mean() |
| 152 | |
| 153 | # Combined jitter degree |
| 154 | combined_jitter = global_jitter + local_jitter |
| 155 | combined_value = combined_jitter.item() |
| 156 | jitter_degree_list.append(combined_value) |
| 157 | per_motion_metrics.append( |
| 158 | { |
| 159 | "id": prompt_dict.get("id"), |
| 160 | "prompt": prompt_dict.get("prompt"), |
| 161 | "value": combined_value, |
| 162 | "evaluation_file": evaluation_file, |
| 163 | "motion_duration": prompt_dict.get("motion_duration"), |
| 164 | } |
| 165 | ) |
| 166 | |
| 167 | return { |
| 168 | "aggregate": summarize_scores(jitter_degree_list), |
| 169 | "per_motion": per_motion_metrics, |
| 170 | } |
| 171 | |
| 172 | def compute_ground_penetration(full_info_path: str, device: str, **kwargs): |
| 173 | """ |
nothing calls this directly
no test coverage detected