3D Gaussian Splatting介绍

3D Gaussian Splatting流程
gsplat的输入是经过COLMAP处理得到的稀疏点云用来初始化,但是在训练之后会变稠密
🚫 标准的 3D Gaussian Splatting 不使用神经网络。
✅ 它是一个 纯参数优化 (non-neural, direct optimization) 的方法。


优化流程:

代码实现:
基于下面的gsplat仓库:
https://docs.gsplat.studio/main/index.htmlhttps://docs.gsplat.studio/main/index.html安装gsplat
bash
conda create --name gsplat -y python=3.8
conda activate gsplat
pip install torch==2.1.2+cu118 torchvision==0.16.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118
conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit
pip install ninja git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
bash
pip install gsplat
这个过程需要安装很多依赖项
下载仓库:
bash
git clone https://github.com/nerfstudio-project/gsplat.git
还需要手动安装一些其他的库:
(在./example/requirements.txt文件下,注释掉这几个并单独安装)
nerfview
fused-ssim
fused-bilagrid
bash
pip install nerfview
pip install git+https://github.com/rahul-goel/fused-ssim/ --no-build-isolation
git clone https://github.com/harry7557558/fused-bilagrid.git
cd fused-bilagrid
pip install . --no-build-isolation
这里需要改一下源代码/data/xxx/projects/gsplat/examples/datasets/colmap.py
,把"no_factor_suffix": 改成True,使得代码可以兼容COLMAP的结果:
python
# Load extended metadata. Used by Bilarf dataset.
self.extconf = {
"spiral_radius_scale": 1.0,
"no_factor_suffix": True, # False
}
最后运行下面的代码即可复现:
data_dir 会自动找到mycolmap_project/sparse/0的模型位置
bash
cd examples
CUDA_VISIBLE_DEVICES=0 python simple_trainer.py default \
--data_dir /data/xxx/projects/colmap/mycolmap_project/ --data_factor 1 \
--result_dir ./results/my_scene
可视化结果:
可以看到gsplat一步步的训练过程,生成的效果越来越精细


但是超出场景的远景视角还是可以看到有很多不足的

可以看到过程中高斯点会越来越多,画面越来越精细

对显存的占用不是很高
下图左侧为高斯重建结果,右侧为原图,可以发现把图拉近之后效果还是可以的
总共14张图片,训练时长在10mins左右,可以选择保存ply文件(但是会很大,因为最后会有很多点,我这个就有120MB)
gsplat的ply文件
gsplat的ply文件格式与普通的ply文件有所不同:
.ply
文件头部是 3D Gaussian Splatting(高斯渲染) 模型导出的点云文件头。
这些字段定义了每个点的属性(不仅仅是 xyz 坐标),而是包含了 颜色、方向、尺度、旋转等参数 ------
也就是"每个点是一个三维高斯分布(3D Gaussian)",而非简单的几何点。
bash
ply
format binary_little_endian 1.0
element vertex 533057
property float x
property float y
property float z
property float f_dc_0
property float f_dc_1
property float f_dc_2
property float f_rest_0
property float f_rest_1
property float f_rest_2
property float f_rest_3
property float f_rest_4
property float f_rest_5
property float f_rest_6
property float f_rest_7
property float f_rest_8
property float f_rest_9
property float f_rest_10
property float f_rest_11
property float f_rest_12
property float f_rest_13
property float f_rest_14
property float f_rest_15
property float f_rest_16
property float f_rest_17
property float f_rest_18
property float f_rest_19
property float f_rest_20
property float f_rest_21
property float f_rest_22
property float f_rest_23
property float f_rest_24
property float f_rest_25
property float f_rest_26
property float f_rest_27
property float f_rest_28
property float f_rest_29
property float f_rest_30
property float f_rest_31
property float f_rest_32
property float f_rest_33
property float f_rest_34
property float f_rest_35
property float f_rest_36
property float f_rest_37
property float f_rest_38
property float f_rest_39
property float f_rest_40
property float f_rest_41
property float f_rest_42
property float f_rest_43
property float f_rest_44
property float opacity
property float scale_0
property float scale_1
property float scale_2
property float rot_0
property float rot_1
property float rot_2
property float rot_3
end_header
解析:


由于 gsplat 并不是从几何角度直接重建三维结构,因此其输出的 PLY 文件 中的点并不完全对应真实空间中的表面位置点。
直接可视化这些点云时,结果往往呈现为一团分布的点,而不是清晰的三维场景结构。这些非几何位置点主要起到**表示环境辐射场或光照分布(appearance / radiance modeling)**的作用,而非真实几何形状。
