(pkl_path)
| 7 | |
| 8 | |
| 9 | def load_pkl(pkl_path): |
| 10 | pkl_path = str(pkl_path) # Convert Path to string if needed |
| 11 | try: |
| 12 | with open(pkl_path, "rb") as f: |
| 13 | return pickle.load(f) |
| 14 | except Exception as e1: |
| 15 | try: |
| 16 | print(f"Pickle failed, trying joblib for {pkl_path}") |
| 17 | return joblib.load(pkl_path) |
| 18 | except Exception as e2: |
| 19 | try: |
| 20 | print(f"Joblib failed, trying torch.load for {pkl_path}") |
| 21 | return torch.load(pkl_path, map_location="cpu") |
| 22 | except Exception as e3: |
| 23 | raise RuntimeError( |
| 24 | f"Failed to load {pkl_path} as pickle, joblib, or torch.\nErrors:\n- pickle: {e1}\n- joblib: {e2}\n- torch: {e3}" |
| 25 | ) |
| 26 | |
| 27 | |
| 28 | def merge_motion_files(pkl_paths): |
no test coverage detected