Anttwo / SuGaR

[CVPR 2024] Official PyTorch implementation of SuGaR: Surface-Aligned Gaussian Splatting for Efficient 3D Mesh Reconstruction and High-Quality Mesh Rendering
https://anttwo.github.io/sugar/
Other
2.12k stars 152 forks source link

--export_uv_textured_mesh / -t ERROR #38

Open HoloDirk opened 8 months ago

HoloDirk commented 8 months ago

Success on install of SuGaR

Success on convertr.py and train.py in quick start.

Problem: cannot convert gaussian splat trained into the textured mesh (--export_uv_textured_mesh / -t )-

I first tried this command to convert to obj/texture - (sugar) C:\Users\Dirk\SuGaR>python train.py -s data/head01 -c output\ -r density [FAILED]

Then I tried - python -Bu train_coarse_density.py -s data/head01 -c output\ [FAILED]

Both of the attempts gave ERROR - train_coarse_density.py: error: unrecognized arguments: -t output\

a snippet of cmd prompt results, I also show 3 different iterations of prompt structures I tried seperated by double spaces , all wrong -

Loading mesh to bind to: ./output/coarse_mesh\head01\sugarmesh_coarse\head01\3Dgs7000_densityestim02_sdfnorm02_level03_decim1000000.ply... RPly: Unable to open file [Open3D WARNING] Read PLY failed: unable to open file: ./output/coarse_mesh\head01\sugarmesh_coarse\head01\3Dgs7000_densityestim02_sdfnorm02_level03_decim1000000.ply Mesh to bind to loaded. Binding radiance cloud to surface mesh... Traceback (most recent call last): File "C:\Users\Dirk\SuGaR\train.py", line 162, in refined_sugar_path = refined_training(refined_args) File "C:\Users\Dirk\SuGaR\sugar_trainers\refine.py", line 393, in refined_training sugar = SuGaR( File "C:\Users\Dirk\SuGaR\sugar_scene\sugar_model.py", line 323, in init scales = scales.clamp_min(0.0000001).reshape(len(faces_verts), -1, 1).expand(-1, self.n_gaussians_per_surface_triangle, 2).clone().reshape(-1, 2) RuntimeError: cannot reshape tensor of 0 elements into shape [0, -1, 1] because the unspecified dimension size -1 can be any value and is ambiguous

(sugar) C:\Users\Dirk\SuGaR>python -Bu train_coarse_density.py -s data/head01 -c output\ -t output\ usage: train_coarse_density.py [-h] [-c CHECKPOINT_PATH] [-s SCENE_PATH] [-o OUTPUT_DIR] [-i ITERATION_TO_LOAD] [--eval EVAL] [-e ESTIMATION_FACTOR] [-n NORMAL_FACTOR] [--gpu GPU] train_coarse_density.py: error: unrecognized arguments: -t output\

(sugar) C:\Users\Dirk\SuGaR>python -Bu train_coarse_density.py -s data/head01 -t output\ usage: train_coarse_density.py [-h] [-c CHECKPOINT_PATH] [-s SCENE_PATH] [-o OUTPUT_DIR] [-i ITERATION_TO_LOAD] [--eval EVAL] [-e ESTIMATION_FACTOR] [-n NORMAL_FACTOR] [--gpu GPU] train_coarse_density.py: error: unrecognized arguments: -t output\

(sugar) C:\Users\Dirk\SuGaR>python -Bu train_coarse_density.py -s data/head01 -t output\ -r density usage: train_coarse_density.py [-h] [-c CHECKPOINT_PATH] [-s SCENE_PATH] [-o OUTPUT_DIR] [-i ITERATION_TO_LOAD] [--eval EVAL] [-e ESTIMATION_FACTOR] [-n NORMAL_FACTOR] [--gpu GPU] train_coarse_density.py: error: unrecognized arguments: -t output\ -r density

cubantonystark commented 8 months ago

Try this:

python train.py -s data/head01 -c output -r "density"

Anttwo commented 8 months ago

Hey @HoloDirk,

I see that you got a loading error for the following path, which is wrong: ./output/coarse_mesh\head01\sugarmesh_coarse\head01\3Dgs7000_densityestim02_sdfnorm02_level03_decim1000000.ply

Are you using Windows? If so, please refer to the following issue for more details: https://github.com/Anttwo/SuGaR/issues/37

Windows uses different conventions than Linux for writing paths, and this is the reason why in your case, the code fails in loading the meshes and models during optimization. I will update the code as soon as possible to handle Windows conventions.

HoloDirk commented 8 months ago

Thank you @cubantonystark, Your recommendation was almost right. Appreciate the help in trying to solve

Thank you @Anttwo for providing me the formatting convention for Windows 11 pro running python and issue #37

I re ran the obj/texture command in Win 11 format: (sugar) C:\Users\Dirk\SuGaR>python -t train.py -s data\head01 -c output\ -r "density"

Same error message.

I then ran (sugar) C:\Users\Dirk\SuGaR>python train.py -s data\head01 -c output\ -t output\ -r "density"

Same error message * Re ran the entire training process using Win command guidelines -

procedure:

  1. (sugar) C:\Users\Dirk\SuGaR>python gaussian_splatting\convert.py -s data\head01 worked

  2. (sugar) C:\Users\Dirk\SuGaR>python gaussian_splatting\convert.py -s data\head01 --skip_matching worked

  3. (sugar) C:\Users\Dirk\SuGaR>python -Bu gaussian_splatting\train.py -s data\head01 -m output\head01\ --iterations 30000 --save_iterations 7000 30000 --checkpoint_iterations 7000 30000 trained

  4. (sugar) C:\Users\Dirk\SuGaR>python train.py -s data\head01\ -c output\head01\ -r "density" Output - FAILED

    • redid step 4 command with - (sugar) C:\Users\Dirk\SuGaR>python -Bu train_coarse_density.py -s data\head01 -c output\head01\ Worked

obj/texture step

  1. (sugar) C:\Users\Dirk\SuGaR>python -t train.py -s data\head01 -c output\ -r "density"
    AND
    (sugar) C:\Users\Dirk\SuGaR>python train.py -s data\head01 -c output\ -r "density"

Both provide ERROR - Loading config output... Performing train/eval split... Traceback (most recent call last): File "C:\Users\Dirk\SuGaR\train.py", line 120, in coarse_sugar_path = coarse_training_with_density_regularization(coarse_args) File "C:\Users\Dirk\SuGaR\sugar_trainers\coarse_density.py", line 286, in coarse_training_with_density_regularization nerfmodel = GaussianSplattingWrapper( File "C:\Users\Dirk\SuGaR\sugar_scene\gs_model.py", line 111, in init cam_list = load_gs_cameras( File "C:\Users\Dirk\SuGaR\sugar_scene\cameras.py", line 31, in load_gs_cameras with open(gs_output_path + 'cameras.json') as f: FileNotFoundError: [Errno 2] No such file or directory: 'output\cameras.json'

Appreciate the continued help.

nocnestudio commented 2 months ago

Hi. Great Job Anttwo. But I'm trying to solve a little problem. Maybe you can advise something? I'm using ubuntu 22.04 (Mint). The train.py vanilla GS training has been successfully completed. The result is an entire composition of files with a beautiful .ply file playing properly. When training tran.py SuGaR for the second time, unfortunately the process starts but does not end because it does not see the camera.json file. Am I doing something wrong or is this some kind of mistake? Below is a view from the terminal.

python train.py -s data/edit -c gaussian_splatting/output/edit -r density Will export a UV-textured mesh as an .obj file. Will export a ply file with the refined 3D Gaussians at the end of the training. Changing sh_levels to match the loaded model: 4 -----Parsed parameters----- Source path: data/edit

Content: 7 Gaussian Splatting checkpoint path: gaussian_splatting/output/edit Content: 5 SUGAR checkpoint path: ./output/coarse/edit/sugarcoarse_3Dgs7000_densityestim02_sdfnorm02/ Iteration to load: 7000 Output directory: ./output/coarse/edit SDF estimation factor: 0.2 SDF better normal factor: 0.2 Eval split: True White background: False

Using device: 0 =========================================================================== PyTorch CUDA memory summary, device ID 0
CUDA OOMs: 0 cudaMalloc retries: 0
===========================================================================
Metric Cur Usage Peak Usage Tot Alloc Tot Freed
---------------------------------------------------------------------------
Allocated memory 0 B 0 B 0 B 0 B
from large pool 0 B 0 B 0 B 0 B
from small pool 0 B 0 B 0 B 0 B
---------------------------------------------------------------------------
Active memory 0 B 0 B 0 B 0 B
from large pool 0 B 0 B 0 B 0 B
from small pool 0 B 0 B 0 B 0 B
---------------------------------------------------------------------------
Requested memory 0 B 0 B 0 B 0 B
from large pool 0 B 0 B 0 B 0 B
from small pool 0 B 0 B 0 B 0 B
---------------------------------------------------------------------------
GPU reserved memory 0 B 0 B 0 B 0 B
from large pool 0 B 0 B 0 B 0 B
from small pool 0 B 0 B 0 B 0 B
---------------------------------------------------------------------------
Non-releasable memory 0 B 0 B 0 B 0 B
from large pool 0 B 0 B 0 B 0 B
from small pool 0 B 0 B 0 B 0 B
---------------------------------------------------------------------------
Allocations 0 0 0 0
from large pool 0 0 0 0
from small pool 0 0 0 0
---------------------------------------------------------------------------
Active allocs 0 0 0 0
from large pool 0 0 0 0
from small pool 0 0 0 0
---------------------------------------------------------------------------
GPU reserved segments 0 0 0 0
from large pool 0 0 0 0
from small pool 0 0 0 0
---------------------------------------------------------------------------
Non-releasable allocs 0 0 0 0
from large pool 0 0 0 0
from small pool 0 0 0 0
---------------------------------------------------------------------------
Oversize allocations 0 0 0 0
---------------------------------------------------------------------------
Oversize GPU segments 0 0 0 0
===========================================================================

Loading config gaussian_splatting/output/edit... Performing train/eval split... Traceback (most recent call last): File "/home/nocnestudio/NocneStudio/3DGS/SuGaR/train.py", line 129, in coarse_sugar_path = coarse_training_with_density_regularization(coarse_args) File "/home/nocnestudio/NocneStudio/3DGS/SuGaR/sugar_trainers/coarse_density.py", line 289, in coarse_training_with_density_regularization nerfmodel = GaussianSplattingWrapper( File "/home/nocnestudio/NocneStudio/3DGS/SuGaR/sugar_scene/gs_model.py", line 125, in init cam_list = load_gs_cameras( File "/home/nocnestudio/NocneStudio/3DGS/SuGaR/sugar_scene/cameras.py", line 34, in load_gs_cameras with open(gs_output_path + 'cameras.json') as f: FileNotFoundError: [Errno 2] No such file or directory: 'gaussian_splatting/output/editcameras.json'

...any advice ;( "No such file or directory" - 100% it's correct directory

THX

nocnestudio commented 2 months ago

Will export a UV-textured mesh as an .obj file. Will export a ply file with the refined 3D Gaussians at the end of the training. Changing sh_levels to match the loaded model: 4 -----Parsed parameters----- Source path: data/edit

Content: 7 Gaussian Splatting checkpoint path: gaussian_splatting/output/edit Content: 5 SUGAR checkpoint path: ./output/coarse/edit/sugarcoarse_3Dgs7000_densityestim02_sdfnorm02/ Iteration to load: 7000 Output directory: ./output/coarse/edit SDF estimation factor: 0.2 SDF better normal factor: 0.2 Eval split: True White background: False

nocnestudio commented 2 months ago

I FOUND SOLUTION - SOLVED !!! ON UBUNTU 22.04 is WORKING. You need to add a slash at the end of the path to the vanilla 3D Gaussian Splatting model. WRONG: python train.py -s data/edit -c gaussian_splatting/output/edit -r density GOOD: python train.py -s data/edit -c gaussian_splatting/output/edit/ -r density

nocnestudio commented 2 months ago

Try this:

WRONG: python train.py -s data/head01 -c output -r "density" GOOD: python train.py -s data/head01 -c output/ -r "density"

I FOUND SOLUTION - SOLVED !!! ON UBUNTU 22.04 is WORKING. You need to add a slash at the end of the path to the vanilla 3D Gaussian Splatting model. WRONG: python train.py -s data/edit -c gaussian_splatting/output/edit -r density GOOD: python train.py -s data/edit -c gaussian_splatting/output/edit/ -r density