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

Function load_joints

mbench/motion_quality.py:11–35  ·  view source on GitHub ↗

Load joints from either .npy or .pt file format. Args: evaluation_file: Path to the evaluation file (.npy or .pt) device: Target device for the tensor Returns: Tensor of shape (T, num_joints, 3)

(evaluation_file: str, device: str = 'cuda')

Source from the content-addressed store, hash-verified

9
10
11def load_joints(evaluation_file: str, device: str = 'cuda') -> torch.Tensor:
12 """
13 Load joints from either .npy or .pt file format.
14
15 Args:
16 evaluation_file: Path to the evaluation file (.npy or .pt)
17 device: Target device for the tensor
18
19 Returns:
20 Tensor of shape (T, num_joints, 3)
21 """
22 if evaluation_file.endswith('.npy'):
23 # Direct numpy array of joints (T, 22, 3)
24 joints = np.load(evaluation_file)
25 return torch.from_numpy(joints).float().to(device)
26 else:
27 # PyTorch dict with 'joints' key
28 data = torch.load(evaluation_file, map_location=device)
29 if isinstance(data, dict) and 'joints' in data:
30 joints = data['joints']
31 if isinstance(joints, np.ndarray):
32 return torch.from_numpy(joints).float().to(device)
33 return joints.float().to(device)
34 else:
35 raise ValueError(f"Unexpected data format in {evaluation_file}")
36
37def find_common_intervals(intervals1, intervals2):
38 """Find common intervals between two sets of intervals."""

Callers 5

compute_jitter_degreeFunction · 0.85
compute_foot_floatingFunction · 0.85
compute_foot_slidingFunction · 0.85
compute_dynamic_degreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected