Skip to main content

Refactored python initialization and training code for InstantSplat

Project description

packaged InstantSplat

Python versions PyPI version Downloads Total downloads CI CI

This repo is the refactored python training and inference code for InstantSplat. Forked from commit 2c5006d41894d06464da53d5495300860f432872. We refactored the original code following the standard Python package structure, while keeping the algorithms used in the code identical to the original version.

Initialization methods:

  • DUST3R (same method used in InstantSplat)
  • MAST3R (same method used in Splatt3R)
  • COLMAP Sparse reconstruct (same method used in gaussian-splatting)
  • COLMAP Dense reconstruct (use patch_match_stereo, stereo_fusion, poisson_mesher and delaunay_mesher in COLMAP to reconstruct dense point cloud for initialization)
  • Masking of keypoints during COLMAP feature extraction (just put your mask into mask folder, e.g. for an image data/xxx/input/012.jpg, the mask would be data/xxx/input_mask/012.jpg.png)
  • VGGT and VGGT + Colmap Bundle Adjustment according to facebookresearch/vggt/demo_colmap.py
  • Map-Anything and Map-Anything with external pose/depth priors

Prerequisites

  • Pytorch (v2.4 or higher recommended)
  • CUDA Toolkit (12.4 recommended, should match with PyTorch version)

Install a colmap executable, e.g. using conda:

conda install conda-forge::colmap

Install mapanything and vggt:

pip install --upgrade "mapanything[all] @ git+https://github.com/facebookresearch/map-anything.git@main"
pip install --upgrade git+https://github.com/facebookresearch/vggt.git@main
pip install --upgrade Pillow hydra-core omegaconf # deps for vggt
pip install --upgrade git+https://github.com/jytime/LightGlue.git#egg=lightglue # deps for vggt

(Optional) Install xformers for faster Depth-Anything V2 inference:

pip install xformers

(Optional) If you have trouble with gaussian-splatting, try to install it from source:

pip install wheel setuptools
pip install --upgrade git+https://github.com/yindaheng98/gaussian-splatting.git@master --no-build-isolation

PyPI Install

pip install --upgrade instantsplat

or build latest from source:

pip install wheel setuptools
pip install --upgrade git+https://github.com/yindaheng98/InstantSplat.git@main --no-build-isolation

Development Install

git clone --recursive https://github.com/yindaheng98/InstantSplat
cd InstantSplat
pip install --target . --upgrade --no-deps .

Download model

wget -P checkpoints/ https://download.europe.naverlabs.com/ComputerVision/DUSt3R/DUSt3R_ViTLarge_BaseDecoder_224_linear.pth
wget -P checkpoints/ https://download.europe.naverlabs.com/ComputerVision/DUSt3R/DUSt3R_ViTLarge_BaseDecoder_512_linear.pth
wget -P checkpoints/ https://download.europe.naverlabs.com/ComputerVision/DUSt3R/DUSt3R_ViTLarge_BaseDecoder_512_dpt.pth
wget -P checkpoints/ https://download.europe.naverlabs.com/ComputerVision/MASt3R/MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric.pth
wget -P checkpoints/ https://huggingface.co/depth-anything/Depth-Anything-V2-Small/resolve/main/depth_anything_v2_vits.pth
wget -P checkpoints/ https://huggingface.co/depth-anything/Depth-Anything-V2-Base/resolve/main/depth_anything_v2_vitb.pth
wget -P checkpoints/ https://huggingface.co/depth-anything/Depth-Anything-V2-Large/resolve/main/depth_anything_v2_vitl.pth
wget -P checkpoints/ https://huggingface.co/facebook/VGGT-1B-Commercial/resolve/main/vggt_1B_commercial.pt --header="Authorization: Bearer $HF_TOKEN"
wget -P checkpoints/ https://download.europe.naverlabs.com/ComputerVision/MUSt3R/MUSt3R_512.pth
wget -P checkpoints/ https://download.europe.naverlabs.com/ComputerVision/Pow3R/Pow3R_ViTLarge_BaseDecoder_512_linear.pth

Configs for map-anything:

git clone --depth 1 --filter=blob:none --sparse https://github.com/facebookresearch/map-anything.git /tmp/map-anything-configs
git -C /tmp/map-anything-configs sparse-checkout set configs
cp -r /tmp/map-anything-configs/configs ./
rm -rf /tmp/map-anything-configs

Running

  1. Initialize coarse point cloud and jointly train 3DGS & cameras
# Option 1: init and train in one command
python -m instantsplat.train -s data/sora/santorini/3_views -d output/sora/santorini/3_views -i 1000 --init dust3r
# Option 2: init and train in two separate commands
python -m instantsplat.initialize -d data/sora/santorini/3_views -i dust3r # init coarse point and save as a Colmap workspace at data/sora/santorini/3_views
python -m instantsplat.train -s data/sora/santorini/3_views -d output/sora/santorini/3_views -i 1000 # train

To enable the optional auto-scaled Depth-Anything V2 wrapper for any initializer, add --with_depth_anything:

python -m instantsplat.initialize -d data/sora/santorini/3_views -i vggt --with_depth_anything
python -m instantsplat.train -s data/sora/santorini/3_views -d output/sora/santorini/3_views -i 1000 --init mapanything --with_depth_anything

Depth format note:

  • Depth-Anything V2 saves inverse depth (1 / depth), which matches the default depth supervision used by 3DGS.
  • The native depth saved by mapanything, mapanything-external, and vggt is regular depth, not inverse depth.
  • When training from those native depth maps without --with_depth_anything, add -o depth_ground_truth_is_inversed=False.

Example:

python -m instantsplat.train -s data/sora/santorini/3_views -d output/sora/santorini/3_views -i 1000 --init vggt -o depth_ground_truth_is_inversed=False
python -m instantsplat.train -s data/sora/santorini/3_views -d output/sora/santorini/3_views -i 1000 --init mapanything-external -o depth_ground_truth_is_inversed=False
  1. Render it
python -m gaussian_splatting.render -s data/sora/santorini/3_views -d output/sora/santorini/3_views -i 1000 --load_camera output/sora/santorini/3_views/cameras.json

See .vscode\launch.json for more command examples.

Usage

See instantsplat.initialize, instantsplat.train and gaussian_splatting.render for full example.

Also check yindaheng98/gaussian-splatting for more detail of training process.

Gaussian models

Use CameraTrainableGaussianModel in yindaheng98/gaussian-splatting

Dataset

Use TrainableCameraDataset in yindaheng98/gaussian-splatting

Initialize coarse point cloud and cameras

from instantsplat.initializer import Dust3rInitializer
image_path_list = [os.path.join(image_folder, file) for file in sorted(os.listdir(image_folder))]
initializer = Dust3rInitializer(...).to(args.device) # see instantsplat/initializer/dust3r/dust3r.py for full options
initialized_point_cloud, initialized_cameras = initializer(image_path_list=image_path_list)

Create camera dataset from initialized cameras:

from instantsplat.initializer import TrainableInitializedCameraDataset
dataset = TrainableInitializedCameraDataset(initialized_cameras).to(device)

Initialize 3DGS from initialized coarse point cloud:

gaussians.create_from_pcd(initialized_point_cloud.points, initialized_point_cloud.colors)

Training

Trainer jointly optimize the 3DGS parameters and cameras, without densification

from instantsplat.trainer import Trainer
trainer = Trainer(
    gaussians,
    dataset=dataset,
    ... # see instantsplat/trainer/trainer.py for full options
)

InstantSplat: Sparse-view SfM-free Gaussian Splatting in Seconds

arXiv Gradio Home PageX youtube youtube

This repository is the official implementation of InstantSplat, an sparse-view, SfM-free framework for large-scale scene reconstruction method using Gaussian Splatting. InstantSplat supports 3D-GS, 2D-GS, and Mip-Splatting.

Free-view Rendering

https://github.com/zhiwenfan/zhiwenfan.github.io/assets/34684115/748ae0de-8186-477a-bab3-3bed80362ad7

TODO List

  • Confidence-aware Point Cloud Downsampling
  • Support 2D-GS
  • Support Mip-Splatting

Acknowledgement

This work is built on many amazing research works and open-source projects, thanks a lot to all the authors for sharing!

Citation

If you find our work useful in your research, please consider giving a star :star: and citing the following paper :pencil:.

@misc{fan2024instantsplat,
        title={InstantSplat: Unbounded Sparse-view Pose-free Gaussian Splatting in 40 Seconds},
        author={Zhiwen Fan and Wenyan Cong and Kairun Wen and Kevin Wang and Jian Zhang and Xinghao Ding and Danfei Xu and Boris Ivanovic and Marco Pavone and Georgios Pavlakos and Zhangyang Wang and Yue Wang},
        year={2024},
        eprint={2403.20309},
        archivePrefix={arXiv},
        primaryClass={cs.CV}
      }

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

instantsplat-1.15.4.1.tar.gz (195.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

instantsplat-1.15.4.1-cp312-cp312-win_amd64.whl (354.8 kB view details)

Uploaded CPython 3.12Windows x86-64

instantsplat-1.15.4.1-cp311-cp311-win_amd64.whl (354.5 kB view details)

Uploaded CPython 3.11Windows x86-64

instantsplat-1.15.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

instantsplat-1.15.4.1-cp310-cp310-win_amd64.whl (353.4 kB view details)

Uploaded CPython 3.10Windows x86-64

instantsplat-1.15.4.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

Details for the file instantsplat-1.15.4.1.tar.gz.

File metadata

  • Download URL: instantsplat-1.15.4.1.tar.gz
  • Upload date:
  • Size: 195.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for instantsplat-1.15.4.1.tar.gz
Algorithm Hash digest
SHA256 a2a0eb5652df54f38ea83cffc7bf59618beb489b64ebfd31eb3ff973bdb098cc
MD5 77c65f4ee03dc34c8d48256b230f86b8
BLAKE2b-256 fa48053cbe0f72215df09a8f2f9f87cc9ba70253f21b42db39a765d4280bf3bd

See more details on using hashes here.

File details

Details for the file instantsplat-1.15.4.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for instantsplat-1.15.4.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 681a37bdadd5b69a7d5e6db48623654f749a106f695d9f60dc43957d75cd5033
MD5 7d8d4fe3c485cd18f00eb6ea486cd7fd
BLAKE2b-256 9a1c4f5f3cee08250fc2bb2283315cbe6def4c10498a42241c075b44da04ee69

See more details on using hashes here.

File details

Details for the file instantsplat-1.15.4.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for instantsplat-1.15.4.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 11848abdde27433ac3b0f46bc51c38d031acbacbb4556b3dbfc046e28cc0b63c
MD5 2677148e15e6dd782500a118a22069ad
BLAKE2b-256 fab8f3f17cf5df9be3f54c1efc7eacc27c9f3a237d8c497d341c86856e5ad1e1

See more details on using hashes here.

File details

Details for the file instantsplat-1.15.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for instantsplat-1.15.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 52428f1613cc8bf3a77a7770d0208f94db5f8adae6970c5ca8575da821d43b55
MD5 7ff790bec71a1b6987357fdf37468b21
BLAKE2b-256 4784eb59ac7869d95f7f1343d11f09609d9bc8560b2e3e8e36ab987cbad88a27

See more details on using hashes here.

File details

Details for the file instantsplat-1.15.4.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for instantsplat-1.15.4.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d1850d0660c8e58c39d82983b1deaee4148124fa3ca46c4974ca030169b0ace5
MD5 9ad15dffa90c0be0e2095412b5647eda
BLAKE2b-256 de213464f6dee29ba62fabd787266fb90f91abb73181ce9fc311214091447047

See more details on using hashes here.

File details

Details for the file instantsplat-1.15.4.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for instantsplat-1.15.4.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 e44d6af99d59b3f9f94326e6c05c1a611865f62ba844f977257a593843f3139b
MD5 19f0726f76f20995f5a17775fcd0d64a
BLAKE2b-256 1dc70f9a636885008ea35fe1020b7b099328c58a820ce5d0b60067833655c5d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page