3D Gaussian Splatting学习记录11.2

这篇具有很好参考价值的文章主要介绍了3D Gaussian Splatting学习记录11.2。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

训练结果可视化的尝试

  • cmd输入以下命令,开始训练
python train.py -s ./dataset/db/drjohnson -m ./dataset/db/drjohnson/output
  • 整个训练(30,000步)大约需要20分钟,但7000步后会保存一个中间模型,效果已经很不错了。训练结束后得到output文件
  • 在Ubuntu 22.04上,运行以下命令来构建可视化工具:
# Dependencies
sudo apt install -y libglew-dev libassimp-dev libboost-all-dev libgtk-3-dev libopencv-dev libglfw3-dev libavdevice-dev libavcodec-dev libeigen3-dev libxxf86vm-dev libembree-dev
# Project setup
cd SIBR_viewers
cmake -Bbuild . -DCMAKE_BUILD_TYPE=Release # add -G Ninja to build faster
cmake --build build -j24 --target install
  • 安装后,找到SIBR_gaussianViewer_app二进制文件,并以模型的路径作为参数运行它:
SIBR_gaussianViewer_app -m ./dataset/db/drjohnson/output

代码细节

参考​​​​​​​AI葵的代码讲解

cuda_rasterizer文件夹中,forward.cu文件的preprocessCUDA函数

(1)计算投影出来的半径圆心等,把椭圆近似成圆;

  • line200,将3D点的矩阵投影;
	// Transform point by projecting
	float3 p_orig = { orig_points[3 * idx], orig_points[3 * idx + 1], orig_points[3 * idx + 2] };
	float4 p_hom = transformPoint4x4(p_orig, projmatrix);
	float p_w = 1.0f / (p_hom.w + 0.0000001f);
	float3 p_proj = { p_hom.x * p_w, p_hom.y * p_w, p_hom.z * p_w };
  • line215,计算椭球投影成椭圆的样子,用对称2D矩阵记录abbc;
	// Compute 2D screen-space covariance matrix
	float3 cov = computeCov2D(p_orig, focal_x, focal_y, tan_fovx, tan_fovy, cov3D, viewmatrix);
  • line229,求矩阵特征值,解出椭圆的半径,取长轴的半径;
	float mid = 0.5f * (cov.x + cov.z);
	float lambda1 = mid + sqrt(max(0.1f, mid * mid - det));
	float lambda2 = mid - sqrt(max(0.1f, mid * mid - det));
	float my_radius = ceil(3.f * sqrt(max(lambda1, lambda2)));
  • line243,计算每个高斯的颜色
	// If colors have been precomputed, use them, otherwise convert
	// spherical harmonics coefficients to RGB color.
	if (colors_precomp == nullptr)
	{
		glm::vec3 result = computeColorFromSH(idx, D, M, (glm::vec3*)orig_points, *cam_pos, shs, clamped);
		rgb[idx * C + 0] = result.x;
		rgb[idx * C + 1] = result.y;
		rgb[idx * C + 2] = result.z;
	}

(2)计算圆所覆盖的像素,即高斯对颜色的贡献。一种加速的方式是,将整张图片分割成很多16*16的小格子,将与圆有交集的格子近似;

  • line235,getRect函数计算圆覆盖了哪些tile
	getRect(point_image, my_radius, rect_min, rect_max, grid);
  • line249,保存各个值,其中tilesTouch存储了所覆盖的tile
	// Store some useful helper data for the next steps.
	depths[idx] = p_view.z;
	radii[idx] = my_radius;
	points_xy_image[idx] = point_image;
	// Inverse 2D covariance and opacity neatly pack into one float4
	conic_opacity[idx] = { conic.x, conic.y, conic.z, opacities[idx] };
	tiles_touched[idx] = (rect_max.y - rect_min.y) * (rect_max.x - rect_min.x);

(3)计算每个Gaussian的前后顺序(深度),还有alpha blending;

  • 排顺序,tile(32位的编号)+gaussian(32位)

cuda_rasterizer文件夹中,forward.cu文件的renderCUDA函数

(4)计算每个像素的颜色文章来源地址https://www.toymoban.com/news/detail-761956.html

  • line263,把每个tile当做一个block,每一个block里的thread就是tile的pixel
// Main rasterization method. Collaboratively works on one tile per
// block, each thread treats one pixel. Alternates between fetching 
// and rasterizing data.
template <uint32_t CHANNELS>
__global__ void __launch_bounds__(BLOCK_X * BLOCK_Y)
renderCUDA(
	const uint2* __restrict__ ranges,
	const uint32_t* __restrict__ point_list,
	int W, int H,
	const float2* __restrict__ points_xy_image,
	const float* __restrict__ features,
	const float4* __restrict__ conic_opacity,
	float* __restrict__ final_T,
	uint32_t* __restrict__ n_contrib,
	const float* __restrict__ bg_color,
	float* __restrict__ out_color)
  • line295,存在共享内存里,读取一次就好
	// Allocate storage for batches of collectively fetched data.
	__shared__ int collected_id[BLOCK_SIZE];
	__shared__ float2 collected_xy[BLOCK_SIZE];
	__shared__ float4 collected_conic_opacity[BLOCK_SIZE];
  • line300,T是透过率,穿过越多gaussian就越小,小到一定程度就提前终止,contributor记录经过了多少gaussian
	// Initialize helper variables
	float T = 1.0f;
	uint32_t contributor = 0;
	uint32_t last_contributor = 0;
	float C[CHANNELS] = { 0 };
  • line333,d是gaussian到中心的距离,power计算点在gaussian分布的概率
			// Resample using conic matrix (cf. "Surface 
			// Splatting" by Zwicker et al., 2001)
			float2 xy = collected_xy[j];
			float2 d = { xy.x - pixf.x, xy.y - pixf.y };
			float4 con_o = collected_conic_opacity[j];
			float power = -0.5f * (con_o.x * d.x * d.x + con_o.z * d.y * d.y) - con_o.y * d.x * d.y;
			if (power > 0.0f)
				continue;
  • line343,透明度随着概率的减小而减小
			// Eq. (2) from 3D Gaussian splatting paper.
			// Obtain alpha by multiplying with Gaussian opacity
			// and its exponential falloff from mean.
			// Avoid numerical instabilities (see paper appendix). 
			float alpha = min(0.99f, con_o.w * exp(power));
			if (alpha < 1.0f / 255.0f)
				continue;
			float test_T = T * (1 - alpha);
			if (test_T < 0.0001f)
			{
				done = true;
				continue;
			}

到了这里,关于3D Gaussian Splatting学习记录11.2的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 3D Gaussian Splatting的使用

    今年SIGGRAPH最佳论文,学习了一下,果然厉害,具体论文原理就不说了,一搜都有,主要是看看怎么用,自己能不能把身边的场景快速建个模。 赶紧记录下,好像这几天在这个基础上又有很多花样出来了… 我的系统是Ubuntu22.04。 开源作者已经都弄的很详细了,也有教程。 首

    2024年02月04日
    浏览(33)
  • 3D Gaussian Splatting 渲染过程

    给定一组三维高斯点,渲染步骤大致为:1.camera space转成ray space 2.对像平面进行分块,然后对高斯排序 3.正投影发出射线进行α-blending 这个步骤将NeRF中的投影过程变为了正投影,引入了ray space的概念,让3D Gaussian 变为2D Gaussian. 透视投影和正投影                    一般的渲

    2024年01月20日
    浏览(55)
  • 【辐射场】3D Gaussian Splatting

      , 3D Gaussian Splatting,下文简称3DGS,是好一段时间以来在三维内容创作和三维重建领域比较有热度的一项技术。 它属于 基于图像的三维重建方法 ,意思就是你对现实物体或者场景拍照片,就能给你训练成一个场景模型,能够被渲染出来给你看。 它产生的模型可以作为三维

    2024年02月03日
    浏览(31)
  • 3D Gaussian Splatting:论文原理分析

    标题:3D Gaussian Splatting for Real-Time Radiance Field Rendering 作者:Bernhard Kerbl、Georgios Kopanas、Thomas Leimkühler和George Drettakis,来自法国Inria、Université Côte d\\\'Azur和德国Max-Planck-Institut für Informatik。 发表时间:2023年8月,ACM Transactions on Graphics上,卷号42,编号4 提出了一种名为3D Gaussia

    2024年01月23日
    浏览(35)
  • Awesome 3D Gaussian Splatting Resources

    GitHub - MrNeRF/awesome-3D-gaussian-splatting: Curated list of papers and resources focused on 3D Gaussian Splatting, intended to keep pace with the anticipated surge of research in the coming months. 3D Gaussian Splatting简明教程 - 知乎 

    2024年01月20日
    浏览(43)
  • 3D Gaussian Splatting文件的压缩【3D高斯泼溅】

    在上一篇文章中,我开始研究高斯泼溅(3DGS:3D Gaussian Splatting)。 它的问题之一是数据集并不小。 渲染图看起来不错。 但“自行车”、“卡车”、“花园”数据集分别是一个 1.42GB、0.59GB、1.35GB 的 PLY 文件。 它们几乎按原样加载到 GPU 内存中作为巨大的结构化缓冲区,因此

    2024年02月03日
    浏览(22)
  • 3d gaussian splatting笔记(paper部分翻译)

    本文为3DGS paper的部分翻译。 基于点的𝛼混合和 NeRF 风格的体积渲染本质上共享相同的图像形成模型。 具体来说,颜色 𝐶 由沿射线的体积渲染给出: 其中密度 𝜎、透射率 𝑇 和颜色 c 的样本是沿着射线以间隔 𝛿 𝑖 采集的。 这可以重写为 典型的基于神经点的方法通过

    2024年01月24日
    浏览(32)
  • 3D高斯泼溅(Gaussian Splatting)通俗解释

    项目:3D Gaussian Splatting for Real-Time Radiance Field Rendering 代码:GitHub - graphdeco-inria/gaussian-splatting: Original reference implementation of \\\"3D Gaussian Splatting for Real-Time Radiance Field Rendering\\\" 功能:拍摄一段视频或多张图片,可以重建3维场景并能实时渲染。 优点:质量高、速度快。 缺点:占用

    2024年02月22日
    浏览(43)
  • 3D Gaussian Splatting:用于实时的辐射场渲染

    Paper : Kerbl B, Kopanas G, Leimkühler T, et al. 3d gaussian splatting for real-time radiance field rendering[J]. ACM Transactions on Graphics (ToG), 2023, 42(4): 1-14. Introduction : https://repo-sam.inria.fr/fungraph/3d-gaussian-splatting/ Code : https://github.com/graphdeco-inria/gaussian-splatting 3D Gaussian Splatting 是 Siggraph 2023 的 Best Paper,法

    2024年02月05日
    浏览(32)
  • 3D Gaussian Splatting 训练自己的数据scene

    目录 训练教程: 1 colmap安装: 2.1生成初始点云 2.2训练流程 读ColmapScene

    2024年03月25日
    浏览(40)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包