Lay3rss / SuGaR

Forked repo of "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
0 stars 0 forks source link

Training steps of train.py #3

Open rebecca-lay3rs opened 4 months ago

rebecca-lay3rs commented 4 months ago

1. train_coarse.py

python gaussian_splatting/convert.py -s data/Bureau/ python gaussian_splatting/train.py -s data/Bureau_sdf_low_poly/ --iterations 7000 -m outputs_GS/Bureau python train.py -s data/Bureau_sdf_low_poly/ -c outputs_GS/Bureau/ -r "sdf" --low_poly True

2. extract_mesh.py

'-s', '--scene_path', type=str, help='path to the scene data to use

'-c', '--checkpoint_path', type=str, help='path to the vanilla 3D Gaussian Splatting Checkpoint to load

'-i', '--iteration_to_load', type=int, default=7000, help='iteration to load

'-m', '--coarse_model_path', type=str, default=None, help=''coarse Sugar model to load

'-l', '--surface_level', type=float, default=None, help='Surface level to extract the mesh at. If None, will extract levels 0.1, 0.3 and 0.5

'-d', '--decimation_target', type=int, default=None, help='Target number of vertices to decimate the mesh to. If None, will decimate to 200_000 and 1_000_000

'-o', '--mesh_output_dir', type=str, default=None, help='path to the output directory

'-b', '--bboxmin', type=str, default=None, help='Min coordinates to use for foreground

'-B', '--bboxmax', type=str, default=None, help='Max coordinates to use for foreground

'--center_bbox', type=str2bool, default=False, help='If True, center the bounding box. Default is False

'--gpu', type=int, default=0, help='Index of GPU device to use

--eval', type=str2bool, default=True, help='Use eval split.

'--use_centers_to_extract_mesh', type=str2bool, default=False, help='If True, just use centers of the gaussians to extract mesh

'--use_marching_cubes', type=str2bool, default=False, help='If True, use marching cubes to extract mesh

'--use_vanilla_3dgs', type=str2bool, default=False,help='If True, use vanilla 3DGS to extract mesh

calls extract_mesh_from_coarse_sugar() in sugar_extractors/coarse_mesh.py : changed bg_bbox_factor from 4 to 1 (as for angel and statues).

    # Mesh computation parameters
    fg_bbox_factor = 1.  # 1.
    bg_bbox_factor = 1.  # 4.
    poisson_depth = 10  # 10
    decimate_mesh = True
    clean_mesh = True

python extract_mesh.py -s data/Bureau_sdf_low_poly_bgfactor_1/ -c outputs_GS/Bureau/ -i 7000 -m output/coarse/Bureau_sdf_low_poly/sugarcoarse_3Dgs7000_sdfestim02_sdfnorm02/15000.pt -l 0.3 -d 200000 -o output/coarse_mesh

3. train_refined.py

'-s', '--scene_path', type=str, help='path to the scene data to use.') 

'-c', '--checkpoint_path', type=str, help='path to the vanilla 3D Gaussian Splatting Checkpoint to load.')  

'-m', '--mesh_path', type=str, help='Path to the extracted mesh .ply file to use for refinement.')  

'-o', '--output_dir',type=str, default=None, help='path to the output directory.')  

'-i', '--iteration_to_load', type=int, default=7000, help='iteration to load.')  

'-n', '--normal_consistency_factor', type=float, default=0.1, help='Factor to multiply the normal consistency loss by.')  

'-g', '--gaussians_per_triangle', type=int, default=1, help='Number of gaussians per triangle.')  

'-v', '--n_vertices_in_fg', type=int, default=1_000_000, help='Number of vertices in the foreground (Mesh resolution). Used for computing learning rates.')  

'-f', '--refinement_iterations', type=int, default=15_000, help='Number of refinement iterations.')

'-b', '--bboxmin', type=str, default=None, help='Min coordinates to use for foreground.')  

'-B', '--bboxmax', type=str, default=None, help='Max coordinates to use for foreground.')  

'--eval', type=str2bool, default=True, help='Use eval split.')

'--gpu', type=int, default=0, help='Index of GPU device to use.')

'--export_ply', type=str2bool, default=True, help='If True, export a ply files with the refined 3D Gaussians at the end of the training.')

that calls refined_training() function in sugar_trainers/refine.py

python train_refined.py -s data/Bureau_sdf_low_poly_bgfactor_1/ -c outputs_GS/Bureau/ -i 7000 -m output/coarse_mesh/Bureau_sdf_low_poly_bgfactor_1/sugarmesh_3Dgs7000_sdfestim02_sdfnorm02_level03_decim200000.ply -o output/refined_mesh/data/Bureau_sdf_low_poly_bgfactor_1/ -v 200000

3. extract_refined_mesh_with_texture.py

   '-s', '--scene_path',
                        type=str, 
                        help='(Required) path to the scene data to use.')  # --OK
  ('-i', '--iteration_to_load', 
                        type=int, default=7000, 
                        help='iteration to load.')  # --OK
   ('-c', '--checkpoint_path', 
                        type=str, 
                        help='(Required) path to the vanilla 3D Gaussian Splatting Checkpoint to load.')  # --OK
   ('-m', '--refined_model_path',
                        type=str, 
                        help='(Required) Path to the refine model checkpoint.')  # --OK
   ('-o', '--mesh_output_dir',
                        type=str, 
                        default=None, 
                        help='path to the output directory.')  # --OK
   ('-n', '--n_gaussians_per_surface_triangle',
                        default=None, type=int, help='Number of gaussians per surface triangle.')  # --OK
   ('--square_size',
                        default=None, type=int, help='Size of the square to use for the texture.')  # --OK

   ('--eval', type=str2bool, default=True, help='Use eval split.')
   ('-g', '--gpu', type=int, default=0, help='Index of GPU to use.')

    # Optional postprocessing
    parser.add_argument('--postprocess_mesh', type=str2bool, default=False, 
                        help='If True, postprocess the mesh by removing border triangles with low-density. '
                        'This step takes a few minutes and is not needed in general, as it can also be risky. '
                        'However, it increases the quality of the mesh in some cases, especially when an object is visible only from one side.')  # --OK
    parser.add_argument('--postprocess_density_threshold', type=float, default=0.1,
                        help='Threshold to use for postprocessing the mesh.')  # --OK
    parser.add_argument('--postprocess_iterations', type=int, default=5,
                        help='Number of iterations to use for postprocessing the mesh.')  # --OK

python extract_refined_mesh_with_texture.py -s data/Bureau_sdf_low_poly_bgfactor_1/ -c outputs_GS/Bureau/ -i 7000 -m output/refined/Bureau_sdf_low_poly_bgfactor_1/sugarfine_3Dgs7000_sdfestim02_sdfnorm02_level03_decim200000_normalconsistency01_gaussperface1/15000.pt -o output/refined_mesh/Bureau_sdf_low_poly_bgfactor_1