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')
| 9 | |
| 10 | |
| 11 | def 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 | |
| 37 | def find_common_intervals(intervals1, intervals2): |
| 38 | """Find common intervals between two sets of intervals.""" |
no outgoing calls
no test coverage detected