Refactored python initialization and training code for InstantSplat
Project description
packaged InstantSplat
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_mesheranddelaunay_mesherin COLMAP to reconstruct dense point cloud for initialization) - Masking of keypoints during COLMAP feature extraction (just put your mask into
maskfolder, e.g. for an imagedata/xxx/input/012.jpg, the mask would bedata/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
- 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 V2saves inverse depth (1 / depth), which matches the default depth supervision used by 3DGS.- The native depth saved by
mapanything,mapanything-external, andvggtis 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
- 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
Free-view Rendering
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file instantsplat-1.15.3.1.tar.gz.
File metadata
- Download URL: instantsplat-1.15.3.1.tar.gz
- Upload date:
- Size: 194.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f8680ac65546e4b3170b48592d28f6eae9520c0ff0864ff57ccb6bfcdf99fa4
|
|
| MD5 |
f98e33824e5466518fdceb82100d1086
|
|
| BLAKE2b-256 |
cfd924e6bdaa6745f03ddc83d5c359ca30eaefaab5b9698a3fe6d72783934c62
|
File details
Details for the file instantsplat-1.15.3.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: instantsplat-1.15.3.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 354.3 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06c5474d70e023a9fef645f843c8014cc92d32cf6490dcfc064410dea9094d0a
|
|
| MD5 |
77189ccbe38664a4cf99962ff23f92b7
|
|
| BLAKE2b-256 |
2c1f0bd3f7eedf0572a259e6964b23a80cb9a5e990c136e485c8fdbdda43e360
|
File details
Details for the file instantsplat-1.15.3.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: instantsplat-1.15.3.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 354.0 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74d1b1722d05e2411f87dd40f3d114931d0147c3a9d59567cd924d23827ab5da
|
|
| MD5 |
3afe8e21871c60442a61bcd543d407c3
|
|
| BLAKE2b-256 |
aa34ebb7b8b872381fda7ef26292824a90723e4c4b97ab29ebcd52a7d727ee2e
|
File details
Details for the file instantsplat-1.15.3.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: instantsplat-1.15.3.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dee2139bfc50ea7675f1cdcb09bed68278a5853f403802dd5ab09fd19e5fa1dd
|
|
| MD5 |
194195597978c6989a26598eead66ebb
|
|
| BLAKE2b-256 |
65bd5762785b19d5ffbe71a4458d5bb035d38699f908304d82c5a0dd2ce8ea7e
|
File details
Details for the file instantsplat-1.15.3.1-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: instantsplat-1.15.3.1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 352.9 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce7741cfcc0143f571caa461937cde1a8f6920fa0d0d234e5bbea532fe9766e7
|
|
| MD5 |
d87451bb29cbaf36332cd9f9a900f3a7
|
|
| BLAKE2b-256 |
c9730af4f2b80727e4df7d30bf8425e31f9e90a918de100284dd74d4c2ea2f54
|
File details
Details for the file instantsplat-1.15.3.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: instantsplat-1.15.3.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58604dd7f4a1c771a06419b1b55e9a983d6712615096a82ed9ca1e8556a2dffd
|
|
| MD5 |
feca2d5aaecff5400a179b909fb1ee1e
|
|
| BLAKE2b-256 |
780e97a1cf1bedd4b52cb088451a82b018e14bc1b9c2f77452a49f530eaf41a9
|