本项目yq010105/NeRF-Mine (github.com)基于Instant-nsr-pl(NSR,NGP,PytorchLightning)代码构建

  • 保留 omegaconf、nerfacc、Mip-nerf_loss,类似文件结构
  • 去除 pytorch-lightning 框架,使用 pytorch

NeRF 主要部分:

  • 神经网络结构 —> 训练出来模型,即 3D 模型的隐式表达
    • 网络类型一般为 MLP,相当于训练一个函数,输入采样点的位置,可以输出该点的信息(eg: density, sdf, color…)
  • 采样方式:沿着光线进行采样获取采样点
  • 位置编码:对采样点的位置 xyz 和方向 dir 进行编码,使得 MLP 的输入为高频的信息
  • 数学相关:光线的生成、坐标变换、体渲染公式、BRDF……
  • 体渲染函数:
    • NeRF:$\mathrm{C}(r)=\int_{\mathrm{t}_{\mathrm{n}}}^{\mathrm{t}_{\mathrm{f}}} \mathrm{T}(\mathrm{t}) \sigma(\mathrm{r}(\mathrm{t})) \mathrm{c}(\mathrm{r}(\mathrm{t}), \mathrm{d}) \mathrm{dt} =\sum_{i=1}^{N} T_{i}\left(1-\exp \left(-\sigma_{i} \delta_{i}\right)\right) \mathbf{c}_{i}$
      • 不透明度$\sigma$,累计透光率 —> 权重
      • 颜色值
    • Neus:$C(\mathbf{o},\mathbf{v})=\int_{0}^{+\infty}w(t)c(\mathbf{p}(t),\mathbf{v})\mathrm{d}t$
      • sdf, dirs, gradients, invs —> $\alpha$ —> 权重
      • 颜色值
    • NeRO:$\mathbf{c}(\omega_{0})=\mathbf{c}_{\mathrm{diffuse}}+\mathbf{c}_{\mathrm{specular}} =\int_{\Omega}(1-m)\frac{\mathbf{a}}{\pi}L(\omega_{i})(\omega_{i}\cdot\mathbf{n})d\omega_{i} + \int_{\Omega}\frac{DFG}{4(\omega_{i}\cdot\mathbf{n})(\omega_{0}\cdot\mathbf{n})}L(\omega_{i})(\omega_{i}\cdot\mathbf{n})d\omega_{i}$
      • 漫反射颜色:Light(直射光),金属度 m、反照率 a
      • 镜面反射颜色:Light(直射光+间接光),金属度 m、反照率 a、粗糙度$\rho$ ,碰撞概率 occ_prob,间接光碰撞 human 的 human_light
      • 详情见NeRO Code
  • 隐式模型导出(.stl、.obj、.ply 等)显式模型(Marching Cube):利用 trimesh,torchmcubes,mcubes 等库
    • 根据 sdf 和 threshold,获取物体表面的 vertices 和 faces(如需还要生成 vertices 对应的 colors)。
    • 然后根据 vertices、faces 和 colors,由 trimesh 生成 mesh 并导出模型为 obj 等格式

Future:

  • [ ] 消除颜色 or 纹理与几何的歧义,Neus(X—>MLP—>SDF)的方法会将物体的纹理建模到物体的几何中
  • [x] 只关注前景物体的建模,可以结合 SAM 将图片中的 interest object 分割出来: Rembg分割后效果也不好
Read more »

Title Human Performance Modeling and Rendering via Neural Animated Mesh
Author Fuqiang Zhao, Yuheng Jiang, Kaixin Yao, Jiakai Zhang, Liao Wang, Haizhao Dai, Yuhui Zhong, Yingliang Zhang Minye Wu, Lan Xu, Jingyi Yu
Conf/Jour SIGGRAPH Asia 2022
Year 2022
Project Human Performance Modeling and Rendering via Neural Animated Mesh (zhaofuq.github.io)
Paper Human Performance Modeling and Rendering via Neural Animated Mesh (readpaper.com)

可以理解为对Neus使用多分辨率哈希编码进行加速

  • 使用TSDF代替SDF
  • 有限差分函数计算SDF的梯度,在tiny-CUDAnn并未集成,公开了自己的CUDAC++代码

pipeline

不足:

  • 数据集需要手动mask
Read more »

Neus代码的理解

NeRF与Neus相机坐标系的对比:

image.png

Method Pixel to Camera coordinate
NeRF $\vec d = \begin{pmatrix} \frac{i-\frac{W}{2}}{f} \\ -\frac{j-\frac{H}{2}}{f} \\ -1 \\ \end{pmatrix}$ , $intrinsics = K = \begin{bmatrix} f & 0 & \frac{W}{2} \\ 0 & f & \frac{H}{2} \\ 0 & 0 & 1 \\ \end{bmatrix}$
Neus $\vec d = intrinsics^{-1} \times pixel = \begin{bmatrix} \frac{1}{f} & 0 & -\frac{W}{2 \cdot f} \\ 0 & \frac{1}{f} & -\frac{H}{2 \cdot f} \\ 0 & 0 & 1 \\ \end{bmatrix} \begin{pmatrix} i \\ j \\ 1 \\ \end{pmatrix} = \begin{pmatrix} \frac{i-\frac{W}{2}}{f} \\ \frac{j-\frac{H}{2}}{f} \\ 1 \\ \end{pmatrix}$
Read more »

Title Instant Neural Graphics Primitives with a Multiresolution Hash Encoding
Author Thomas Müller Alex Evans Christoph Schied Alexander Keller
Conf/Jour ACM Transactions on Graphics (SIGGRAPH 2022)
Year 2022
Project Instant Neural Graphics Primitives with a Multiresolution Hash Encoding (nvlabs.github.io)
Paper Instant Neural Graphics Primitives with a Multiresolution Hash Encoding (readpaper.com)

哈希函数在cuda(cuda c++)中进行编程,不需深挖具体代码,初学只需理解多分辨率哈希编码思想。i.e.目前只需要学会使用tiny-cuda-nn即可:NVlabs/tiny-cuda-nn: Lightning fast C++/CUDA neural network framework (github.com)

哈希编码思想:
哈希编码后的输出值的数量与L(分辨率数量)、F(特征向量维度)有关,eg: L=16,F=2,则输入一个坐标xyz,根据多分辨率体素网格,插值出来L个特征值,每个特征值维度为2,因此输出值的维度为32

image.png

L为分辨率数量,l为分辨率序号。示例中L=2,$N_{0}= N_{min} =2$ , $N_{1}= N_{max}= 3$ , $b = \frac{3}{2}$

  • L:多分辨率
  • T:每个分辨率下有T个特征向量
  • F:特征向量的维度
  • 最小和最大分辨率:$N_{min} , N_{max}$
  • b:每个level的缩放per_level_scale $b= e^{\frac{ln(\frac{N_{max}}{N_{min}})}{L-1}}$

image.png

Read more »

不要乱用 git reset —hard commit_id 回退 git commit 版本

Read more »

NeRF相关的论文 at CVPR/ICCV/ECCV/NIPS/ICML/ICLR/SIGGRAPH
计算机视觉顶会2022截稿时间及会议时间_ijcai2024截稿日期-CSDN博客
ccf-deadlines (ccfddl.github.io)

My post Brief description status
NeRF + Code NeRF 原理 + 代码理解 Completed
NeuS + Code 表面重建方法 SDFNetwork Completed
InstantNGP + Tiny-cuda-nn 加速 NeRF 的训练和推理 Completed(Tcnn)
Instant-nsr-pl + Code Neus+Tcnn+NSR+pl Completed
Instant-NSR + Code 快速表面重建 Completed
NeRO + Code 考虑镜面和漫反射的体渲染函数 In Processing
NeRF 基于 Instant-nsr-pl 创建的项目 Completed

Related link : 3D Reconstruction | awesome-NeRF-papers

Read more »