From 17211cc044e470bfcebfcd6b30f7c08d4bdf21e0 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Wed, 20 Mar 2024 19:06:37 +0000 Subject: [PATCH] width/height mismatch fix, cleanup --- model.cpp | 4 +--- opensplat.cpp | 4 +++- simple_trainer.cpp | 4 ++-- vendor/gsplat-cpu/gsplat_cpu.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/model.cpp b/model.cpp index ebf56f0..ae02d2b 100644 --- a/model.cpp +++ b/model.cpp @@ -127,7 +127,7 @@ torch::Tensor Model::forward(Camera& cam, int step){ conics = p[3]; numTilesHit = p[4]; #else - throw std::runtime_error("GPU support not built"); + throw std::runtime_error("GPU support not built, use --cpu"); #endif } @@ -143,7 +143,6 @@ torch::Tensor Model::forward(Camera& cam, int step){ int degreesToUse = (std::min)(step / shDegreeInterval, shDegree); torch::Tensor rgbs; - std::cerr << "HERE"; if (device == torch::kCPU){ rgbs = SphericalHarmonicsCPU::apply(degreesToUse, viewDirs, colors); }else{ @@ -152,7 +151,6 @@ torch::Tensor Model::forward(Camera& cam, int step){ #endif } - std::cerr << "THERE" << camDepths; rgbs = torch::clamp_min(rgbs + 0.5f, 0.0f); diff --git a/opensplat.cpp b/opensplat.cpp index f21c03d..e0c410d 100644 --- a/opensplat.cpp +++ b/opensplat.cpp @@ -77,10 +77,12 @@ int main(int argc, char *argv[]){ const float splitScreenSize = result["split-screen-size"].as(); torch::Device device = torch::kCPU; + int displayStep = 1; if (torch::cuda::is_available() && result.count("cpu") == 0) { std::cout << "Using CUDA" << std::endl; device = torch::kCUDA; + displayStep = 10; }else{ std::cout << "Using CPU" << std::endl; } @@ -120,7 +122,7 @@ int main(int argc, char *argv[]){ torch::Tensor mainLoss = model.mainLoss(rgb, gt, ssimWeight); mainLoss.backward(); - if (step % 10 == 0) std::cout << "Step " << step << ": " << mainLoss.item() << std::endl; + if (step % displayStep == 0) std::cout << "Step " << step << ": " << mainLoss.item() << std::endl; model.optimizersStep(); model.schedulersStep(step); diff --git a/simple_trainer.cpp b/simple_trainer.cpp index c15a0f6..2da1704 100644 --- a/simple_trainer.cpp +++ b/simple_trainer.cpp @@ -147,7 +147,7 @@ int main(int argc, char **argv){ height / 2, height, width); - + outImg = RasterizeGaussiansCPU::apply( p[0], // xys p[1], // radii, @@ -182,7 +182,7 @@ int main(int argc, char **argv){ width, background); #else - throw std::runtime_error("GPU support not built"); + throw std::runtime_error("GPU support not built, use --cpu"); #endif } diff --git a/vendor/gsplat-cpu/gsplat_cpu.cpp b/vendor/gsplat-cpu/gsplat_cpu.cpp index 0fff7d3..250b394 100644 --- a/vendor/gsplat-cpu/gsplat_cpu.cpp +++ b/vendor/gsplat-cpu/gsplat_cpu.cpp @@ -240,8 +240,8 @@ std::tuple< } // Background - for (int i = 0; i < width; i++){ - for (int j = 0; j < height; j++){ + for (int i = 0; i < height; i++){ + for (int j = 0; j < width; j++){ size_t pixIdx = (i * width + j); float T = pFinalTs[pixIdx];