SPARS3R项目使用教程
1. 项目介绍
SPARS3R(Semantic Prior Alignment and Regularization for Sparse 3D Reconstruction)是一个开源项目,旨在通过结合结构从运动(Structure-from-Motion)的准确姿态估计和深度估计的密集点云优势,实现对稀疏视角下的三维重建。该项目通过两个阶段的对齐过程,即全局融合对齐和语义异常值对齐,来提高稀疏视角下的三维重建效果。
2. 项目快速启动
环境搭建
首先,你需要克隆项目仓库并创建一个Python环境:
git clone git@github.com:snldmt/SPARS3R.git
cd SPARS3R
conda create -n spars3r -y python=3.8
conda activate spars3r
安装依赖
接下来,安装所需的Python包:
pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 -f https://download.pytorch.org/whl/torch_stable.html
conda install cudatoolkit-dev=11.3 -c conda-forge
pip install ninja git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
pip install -e .
pip uninstall gsplat
pip install git+https://github.com/nerfstudio-project/gsplat.git@v0.1.11
pip install git+https://github.com/facebookresearch/segment-anything.git
数据集准备
项目支持多个数据集,你可以从以下链接下载:
- Mip-NeRF 360 Dataset: [下载链接]
- Tanks&Temples Datasets: [下载链接]
- MVImgNet Dataset: [下载链接]
运行项目
以下是一个简单的运行流程示例:
# 对齐处理
python train_test_alignment/align_coordinate.py --true_images ${working_dir}/train_sparse/sfm --guess_images ${working_dir}/train+test_sparse/sfm --output_path ${working_dir}/train+test_aligned
# 运行两阶段对齐
python alignment/spars3r_alignment.py --scene ${scene_name} --source_path ${working_dir} --orig_colmap_path ${train+test_aligned_path}
# 训练模型
ns-train splatfacto \
--data ${working_dir} --output-dir results/ \
--timestamp 0 \
colmap --images_path images_train+test \
--colmap-path ${sparse_alignment_output_path}
ns-train splatfacto-tpo \
--data ${working_dir} --output-dir results/ \
--timestamp tpo \
--pipeline.model.test_opt_pose True --pipeline.model.camera_optimizer.mode SO3xR3 \
--load-dir results/splatfacto/0/nerfstudio_models \
colmap --images_path images_train+test \
--colmap-path ${sparse_alignment_output_path} \
--test_opt_pose True
# 评估模型
ns-eval --load-config results/splatfacto/tpo/config.yml
确保替换上述命令中的${working_dir}
、${scene_name}
和${train+test_aligned_path}
等占位符为实际路径和参数。
3. 应用案例和最佳实践
- 案例: 使用SPARS3R对稀疏视角下的室内场景进行三维重建。
- 最佳实践: 在进行三维重建前,确保使用高质量的数据集,并且在训练模型时进行充分的超参数调优。
4. 典型生态项目
- NeRFStudio: SPARS3R项目是基于NeRFStudio构建的,NeRFStudio是一个用于神经辐射场(NeRF)的端到端开源系统。
- Tiny CUDA NN: 用于加速神经网络的CUDA实现库。
以上就是关于SPARS3R项目的使用教程,希望对你有所帮助。