| 159 | self.poses: pp.LieTensor = self.load_poses() |
| 160 | |
| 161 | def load_poses(self) -> pp.LieTensor: |
| 162 | pose_file = Path(self.config.pose_file) |
| 163 | if not pose_file.exists(): |
| 164 | Logger.write("error", f"Cannot read pose file at {pose_file} - File Not Exist!") |
| 165 | raise FileNotFoundError(f"Cannot read pose file at {pose_file} - File Not Exist!") |
| 166 | |
| 167 | poses: pp.LieTensor |
| 168 | match pose_file.suffix: |
| 169 | case ".npy": |
| 170 | import numpy as np |
| 171 | poses_data: torch.Tensor = torch.from_numpy(np.load(str(pose_file))) |
| 172 | case ".pt" | ".pth": |
| 173 | poses_data: torch.Tensor = torch.load(str(pose_file), weights_only=False) |
| 174 | case ".txt": |
| 175 | import numpy as np |
| 176 | poses_data: torch.Tensor = torch.from_numpy(np.loadtxt(str(pose_file))) |
| 177 | case suffix: |
| 178 | raise NameError(f"Cannot handle a file with suffix '{suffix}'. Consider change it to .npy/.pt/.pth/.txt or write a custom loader.") |
| 179 | assert poses_data.ndim == 2 and poses_data.shape[1] == 7 |
| 180 | poses = pp.SE3(poses_data) |
| 181 | return poses |
| 182 | |
| 183 | def predict(self, frame: StereoFrame, flow: torch.Tensor | None, depth: torch.Tensor | None) -> pp.LieTensor: |
| 184 | if self.prev_pose is None or self.prev_gt_pose is None: |