| 259 | } |
| 260 | |
| 261 | void NeuralScene::LoadCheckpoint(const std::string& checkpoint_dir) |
| 262 | { |
| 263 | std::string checkpoint_prefix = checkpoint_dir + "/scene_" + scene->scene_name + "_"; |
| 264 | |
| 265 | if (point_cloud_cuda && std::filesystem::exists(checkpoint_prefix + "points.pth")) |
| 266 | { |
| 267 | torch::load(point_cloud_cuda, checkpoint_prefix + "points.pth"); |
| 268 | |
| 269 | std::cout << "Load Checkpoint points " << point_cloud_cuda->t_position.size(0) |
| 270 | << " max uv: " << point_cloud_cuda->t_index.max().item().toInt() << std::endl; |
| 271 | |
| 272 | SAIGA_ASSERT(point_cloud_cuda->t_position.dtype() == torch::kFloat); |
| 273 | SAIGA_ASSERT(point_cloud_cuda->t_index.dtype() == torch::kInt32); |
| 274 | |
| 275 | SAIGA_ASSERT(point_cloud_cuda->t_position.size(0) == point_cloud_cuda->t_index.size(0)); |
| 276 | SAIGA_ASSERT(point_cloud_cuda->t_position.size(0) == point_cloud_cuda->t_normal.size(0)); |
| 277 | } |
| 278 | |
| 279 | if (texture && std::filesystem::exists(checkpoint_prefix + "texture.pth")) |
| 280 | { |
| 281 | torch::load(texture, checkpoint_prefix + "texture.pth"); |
| 282 | std::cout << "Load Checkpoint texture. Texels: " << texture->NumPoints() |
| 283 | << " Channels: " << texture->TextureChannels() << std::endl; |
| 284 | SAIGA_ASSERT(texture->NumPoints() == point_cloud_cuda->Size()); |
| 285 | SAIGA_ASSERT(texture->TextureChannels() == params->pipeline_params.num_texture_channels); |
| 286 | } |
| 287 | |
| 288 | SAIGA_ASSERT(point_cloud_cuda->t_index.max().item().toInt() <= texture->NumPoints()); |
| 289 | |
| 290 | if (std::filesystem::exists(checkpoint_prefix + "poses.pth")) |
| 291 | { |
| 292 | std::cout << "Load Checkpoint pose" << std::endl; |
| 293 | |
| 294 | std::cout << "First pose before " << poses->Download().front() << std::endl; |
| 295 | |
| 296 | torch::load(poses, checkpoint_prefix + "poses.pth"); |
| 297 | |
| 298 | SAIGA_ASSERT(poses->poses_se3.size(0) == scene->frames.size()); |
| 299 | SAIGA_ASSERT(poses->poses_se3.dtype() == torch::kDouble); |
| 300 | SAIGA_ASSERT(poses->tangent_poses.dtype() == torch::kDouble); |
| 301 | |
| 302 | std::cout << "First pose after " << poses->Download().front() << std::endl; |
| 303 | |
| 304 | DownloadPoses(); |
| 305 | } |
| 306 | |
| 307 | if (std::filesystem::exists(checkpoint_prefix + "intrinsics.pth")) |
| 308 | { |
| 309 | std::cout << "Load Checkpoint intrinsics" << std::endl; |
| 310 | torch::load(intrinsics, checkpoint_prefix + "intrinsics.pth"); |
| 311 | DownloadIntrinsics(); |
| 312 | } |
| 313 | |
| 314 | |
| 315 | if (environment_map && std::filesystem::exists(checkpoint_prefix + "env.pth")) |
| 316 | { |
| 317 | std::cout << "Load Checkpoint environment_map" << std::endl; |
| 318 | torch::load(environment_map, checkpoint_prefix + "env.pth"); |
nothing calls this directly
no test coverage detected