DRGS (Depth-Regularized Optimization for 3D Gaussian Splatting)

repository·main·Indexed 42 days ago

https://github.com/robot0321/depthregularizedgs

A method for high-quality 3D reconstruction from few-shot images that incorporates depth regularization into the Gaussian Splatting optimization process. Includes tools for dataset preparation via COLMAP, training scripts for original 3DGS and DRGS methods, and a pipeline for large-scale automated evaluation.

Tokens
1.4K
Snippets
4
Records
4
Agent score
5%

What's inside DRGS

  1. Run massive evaluations using task scripts

    main

    DRGS provides a pipeline for automated, large-scale experimentation across different seeds, methods, datasets, and k-shots.

    1. Generate Tasks: Edit SCENES, SHOTS, METHODS, and SEED_IDS in scripts/task_producer.py, then run it to create scripts/all_tasks.txt.
    2. Execute Tasks: Run scripts/task_consumer.py pointing to your task list. Use --gpu <id> to specify the device. For multi-GPU runs, create separate task lists for each GPU.
    3. Summarize Results: Use scripts/task_reducer.py with a specific --method <method id> to generate a metric_mean.txt summary.
    # 1. Produce task list
    python scripts/task_producer.py
    
    # 2. Consume tasks (run on GPU 0)
    python scripts/task_consumer.py --tasklist ./scripts/all_tasks.txt --gpu 0
    
    # 3. Reduce/Summarize results
    python scripts/task_reducer.py --method <method id>
  2. Prepare a few-shot dataset from scratch

    main

    To prepare your own dataset for DRGS, follow these three steps:

    1. Image Organization: Ensure images are in a directory structure like <datadir>/images/00000.jpg. If your filenames are non-standard, use scripts/convertImagename.py to normalize them.
    2. COLMAP Reconstruction: Run COLMAP to generate sparse reconstruction. Use the SIMPLE_PINHOLE camera model and --single_camera 1. Convert the sparse model to .txt format.
    3. Sample Selection: Run scripts/select_samples.py to split the data into training and testing sets. You must specify the --dset type (e.g., nerfllff, dtu, mipnerf360, or nerfsynthetic).

    Output: This process generates train.ply and test.ply in the split_visualization/ folder and a split_index.json file.

    # Step 1: Normalize image names
    python scripts/convertImagename.py --imgfolder ./<datadir>/images
    
    # Step 2: COLMAP reconstruction
    colmap automatic_reconstructor --workspace_path ./<datadir> --image_path ./<datadir>/images --camera_model SIMPLE_PINHOLE --single_camera 1 --dense 0 --num_threads 8
    mkdir ./<datadir>/sparse_txt
    colmap model_converter --input_path ./<datadir>/sparse/0 --output_path ./<datadir>/sparse_txt --output_type TXT
    
    # Step 3: Split samples
    # Supported --dset: nerfllff, dtu, mipnerf360, nerfsynthetic
    python scripts/select_samples.py --dset nerfllff --path ./<datadir>
  3. Install DRGS via Conda or Pip

    main

    To use DRGS, you must first clone the repository recursively to include submodules (ZoeDepth, simple-knn, and rasterizer).

    There are two installation paths:

    1. Full Installation: Creates a new Conda environment with all 3DGS dependencies and the depth rasterizer.
    2. Partial Installation: If you already have a 3DGS environment, you can install only the depth rasterizer and pytorch3d.

    Warning: The current rasterizer is an improved version implemented after the arXiv submission. If you require the original implementation, use the first commit of this repository and the first commit of the diff-rasterizer repository.

    # Clone recursively for submodules
    git clone https://github.com/robot0321/DepthRegularizedGS.git --recursive
    
    # Option 1: Full installation
    conda env create --file environment.yml
    conda activate DepthRegularizedGS
    
    # Option 2: Install only rasterizer and pytorch3d (if 3DGS is already installed)
    pip install -e submodules/diff-gaussian-rasterization-depth-acc
    pip install pytorch3d
  4. Train DRGS models

    main

    Use train.py to start training. You can choose between the original 3DGS method or the DRGS method.

    Arguments:

    • -s <datadir>: Path to the prepared dataset.
    • --eval: Enables evaluation mode.
    • --port <port>: Port for visualization.
    • --model_path <outdir>: Directory to save the model.
    • --resolution 1: Training resolution.
    • --kshot <k-shot>: Number of shots (e.g., 5).
    • --seed <seed_id>: Random seed.

    Methods:

    • Original 3DGS (method1): Standard training.
    • DRGS (method2): Add --depth and --usedepthReg to enable depth regularization.
    # Original 3DGS (method1)
    python train.py -s <datadir> --eval --port 6311 --model_path <outdir>/method1 --resolution 1 --kshot 5 --seed 3
    
    # DRGS (method2)
    python train.py -s <datadir> --eval --port 6312 --model_path <outdir>/method2 --resolution 1 --kshot 5 --seed 3 --depth --usedepthReg