From 6a17baef45dffcb4b881117022e2b9e4d5944972 Mon Sep 17 00:00:00 2001 From: Haithem Turki Date: Thu, 7 Apr 2022 01:31:10 -0400 Subject: [PATCH 1/2] save camera exposure as part of snapshot --- src/testbed.cu | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/testbed.cu b/src/testbed.cu index ca8bba119..064c56b54 100644 --- a/src/testbed.cu +++ b/src/testbed.cu @@ -2224,6 +2224,12 @@ void Testbed::save_snapshot(const std::string& filepath_string, bool include_opt m_network_config["snapshot"]["nerf"]["rgb"]["measured_batch_size"] = m_nerf.training.counters_rgb.measured_batch_size; m_network_config["snapshot"]["nerf"]["rgb"]["measured_batch_size_before_compaction"] = m_nerf.training.counters_rgb.measured_batch_size_before_compaction; m_network_config["snapshot"]["nerf"]["dataset"] = m_nerf.training.dataset; + + nlohmann::json::binary_t cam_exposure_json; + size_t cam_exposure_bytes = m_nerf.training.cam_exposure.size() * sizeof(AdamOptimizer); + cam_exposure_json.resize(cam_exposure_bytes); + memcpy(cam_exposure_json.data(), m_nerf.training.cam_exposure.data(), cam_exposure_bytes); + m_network_config["snapshot"]["nerf"]["cam_exposure"] = cam_exposure_json; } m_network_config_path = filepath; @@ -2265,6 +2271,14 @@ void Testbed::load_snapshot(const std::string& filepath_string) { m_loss_scalar = m_network_config["snapshot"]["loss"]; m_trainer->deserialize(m_network_config["snapshot"]); + + if (m_testbed_mode == ETestbedMode::Nerf) { + nlohmann::json::binary_t cam_exposure_json; + size_t cam_exposure_bytes = m_nerf.training.cam_exposure.size() * sizeof(AdamOptimizer); + cam_exposure_json.resize(cam_exposure_bytes); + memcpy(cam_exposure_json.data(), m_nerf.training.cam_exposure.data(), cam_exposure_bytes); + m_network_config["snapshot"]["nerf"]["cam_exposure"] = cam_exposure_json; + } } void Testbed::load_camera_path(const std::string& filepath_string) { From 46ae6e5a338a7e535d6c9b4c38819fa0a057401f Mon Sep 17 00:00:00 2001 From: hturki Date: Wed, 13 Apr 2022 14:49:16 -0400 Subject: [PATCH 2/2] fix identation --- src/testbed.cu | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/testbed.cu b/src/testbed.cu index 064c56b54..3dcd47b5f 100644 --- a/src/testbed.cu +++ b/src/testbed.cu @@ -2225,11 +2225,11 @@ void Testbed::save_snapshot(const std::string& filepath_string, bool include_opt m_network_config["snapshot"]["nerf"]["rgb"]["measured_batch_size_before_compaction"] = m_nerf.training.counters_rgb.measured_batch_size_before_compaction; m_network_config["snapshot"]["nerf"]["dataset"] = m_nerf.training.dataset; - nlohmann::json::binary_t cam_exposure_json; - size_t cam_exposure_bytes = m_nerf.training.cam_exposure.size() * sizeof(AdamOptimizer); - cam_exposure_json.resize(cam_exposure_bytes); - memcpy(cam_exposure_json.data(), m_nerf.training.cam_exposure.data(), cam_exposure_bytes); - m_network_config["snapshot"]["nerf"]["cam_exposure"] = cam_exposure_json; + nlohmann::json::binary_t cam_exposure_json; + size_t cam_exposure_bytes = m_nerf.training.cam_exposure.size() * sizeof(AdamOptimizer); + cam_exposure_json.resize(cam_exposure_bytes); + memcpy(cam_exposure_json.data(), m_nerf.training.cam_exposure.data(), cam_exposure_bytes); + m_network_config["snapshot"]["nerf"]["cam_exposure"] = cam_exposure_json; } m_network_config_path = filepath; @@ -2272,13 +2272,13 @@ void Testbed::load_snapshot(const std::string& filepath_string) { m_trainer->deserialize(m_network_config["snapshot"]); - if (m_testbed_mode == ETestbedMode::Nerf) { - nlohmann::json::binary_t cam_exposure_json; - size_t cam_exposure_bytes = m_nerf.training.cam_exposure.size() * sizeof(AdamOptimizer); - cam_exposure_json.resize(cam_exposure_bytes); - memcpy(cam_exposure_json.data(), m_nerf.training.cam_exposure.data(), cam_exposure_bytes); - m_network_config["snapshot"]["nerf"]["cam_exposure"] = cam_exposure_json; - } + if (m_testbed_mode == ETestbedMode::Nerf) { + nlohmann::json::binary_t cam_exposure_json; + size_t cam_exposure_bytes = m_nerf.training.cam_exposure.size() * sizeof(AdamOptimizer); + cam_exposure_json.resize(cam_exposure_bytes); + memcpy(cam_exposure_json.data(), m_nerf.training.cam_exposure.data(), cam_exposure_bytes); + m_network_config["snapshot"]["nerf"]["cam_exposure"] = cam_exposure_json; + } } void Testbed::load_camera_path(const std::string& filepath_string) {