MCPcopy Index your code
hub / github.com/MotrixLab/ViMoGen / compute_dynamic_degree

Function compute_dynamic_degree

mbench/motion_quality.py:406–446  ·  view source on GitHub ↗

Compute the dynamic degree of the motion based on the average velocity of the joints.

(full_info_path: str, device: str, **kwargs)

Source from the content-addressed store, hash-verified

404 }
405
406def compute_dynamic_degree(full_info_path: str, device: str, **kwargs):
407 """
408 Compute the dynamic degree of the motion based on the average velocity of the joints.
409 """
410 prompt_dict_ls = load_dimension_info(full_info_path, dimension='Dynamic_Degree')
411
412 dynamic_degree_list = []
413 per_motion_metrics = []
414
415 for prompt_dict in tqdm(prompt_dict_ls):
416 evaluation_file = prompt_dict["evaluation_file"]
417 pred_joints = load_joints(evaluation_file, device)
418
419
420 # Global dynamic degree
421 velocity = torch.norm(pred_joints[1:] - pred_joints[:-1], dim=2) # Shape: (T-1, 24)
422 global_dynamic = velocity.mean()
423
424 # Local dynamic degree (remove global translation)
425 local_joints = remove_global_translation(pred_joints)
426 local_velocity = torch.norm(local_joints[1:] - local_joints[:-1], dim=2) # Shape: (T-1, 24)
427 local_dynamic = local_velocity.mean()
428
429 # Combined dynamic degree
430 combined_dynamic = global_dynamic + local_dynamic
431 dynamic_value = combined_dynamic.item()
432 dynamic_degree_list.append(dynamic_value)
433 per_motion_metrics.append(
434 {
435 "id": prompt_dict.get("id"),
436 "prompt": prompt_dict.get("prompt"),
437 "value": dynamic_value,
438 "evaluation_file": evaluation_file,
439 "motion_duration": prompt_dict.get("motion_duration"),
440 }
441 )
442
443 return {
444 "aggregate": summarize_scores(dynamic_degree_list),
445 "per_motion": per_motion_metrics,
446 }

Callers

nothing calls this directly

Calls 4

load_dimension_infoFunction · 0.90
load_jointsFunction · 0.85
summarize_scoresFunction · 0.70

Tested by

no test coverage detected