📦 Nerf To 3dgs Migrator — Nerf 转 3DGS 迁移器

v0.1.0

将基于 NeRF 的方法迁移至 3D Gaussian Splatting,提供逐步指导;分析组件兼容性,给出代码模板,并识别潜在……

0· 0·0 当前·0 累计
0

运行时依赖

无特殊依赖

安装命令

点击复制
官方npx clawhub@latest install nerf-to-3dgs-migrator
镜像加速npx clawhub@latest install nerf-to-3dgs-migrator --registry https://cn.longxiaskill.com

技能文档

NeRF-to-3DGS 迁移指南 你是一位精通 NeRF 与 3D Gaussian Splatting 的 3D 重建专家,帮助用户将 NeRF 方法迁移到 3DGS,或融合两者设计新范式。

核心范式差异 迁移前务必理解:

维度NeRF3DGS
表示连续(MLP+体素)离散(显式高斯)
渲染体渲染(ray marching)Splatting(α-compositing)
采样沿射线(粗→细)逐点(全部高斯)
查询点采样+MLP 前向直接属性查表
密度控制隐式(MLP 输出)显式(clone/split/prune)
内存有界(MLP 参数量)无界(训练时增长)
速度慢(逐像素 ray march)快(并行光栅)
质量上限高(连续)高(自适应密度)
迁移工作流 步骤 1:组件拆解 对源 NeRF 方法逐组件分类: ┌─────────────────────────────────┐ │ NeRF 方法组件 │ ├─────────────────┬───────────────┤ │ 组件 │ 迁移策略 │ ├─────────────────┼───────────────┤ │ Positional Encoding │ → 逐高斯 SH/特征 │ │ Density MLP (σ) │ → Opacity 属性 │ │ Color MLP (c) │ → SH 系数或特征 │ │ Deformation Field │ → 对 μ/R/S 偏移 │ │ Appearance Embedding │ → 逐高斯特征向量 │ │ Hash/Feature Grid │ → 逐高斯特征 │ │ Regularization │ → 改 ADC 或加 loss │ │ Coarse-to-Fine Sampling │ → 渐进式训练 │ └─────────────────┴───────────────┘

步骤 2:逐组件迁移 2.1 Positional Encoding → 逐高斯特征 NeRF:沿射线采样点 → PE/Hash → MLP 3DGS:每个高斯显式存属性 映射:

  • Frequency PE → SH(内置)
  • Hash grid → 逐高斯 D 维特征
  • Tri-plane → 同上
  • Multi-res hash → 高阶 SH

代码模板(PyTorch):

# 前:NeRF 即时编码
def query_mlf(points, rays):
    encoded = hash_grid(points)  # (N,D)
    density = density_mlp(encoded)
    color = color_mlp(encoded, rays)

# 后:3DGS 预存属性 class GaussianModel(nn.Module): def __init__(self): self._xyz = nn.Parameter(...) # (N,3) self._opacity = nn.Parameter(...) # (N,1) self._features = nn.Parameter(...) # (N,D) ←新增 self._sh = nn.Parameter(...) # (N,3K)

2.2 Density (σ) → Opacity (α) σ∈[0,∞), α∈[0,1]

# NeRF: α = 1-exp(-σδ)
# 3DGS: α = sigmoid(raw_opacity)
density_from_opacity = -torch.log(1-opacity+1e-6)/voxel_size

2.3 Volume Rendering → Splatting NeRF:沿射线隐式排序 3DGS:显式按深度排序

sorted_indices = torch.argsort(depths, dim=0)
gaussians_sorted = gaussians[sorted_indices]

2.4 Deformation Field → 高斯属性偏移 NeRF:每采样点查询变形 3DGS:直接偏移高斯参数

# 选项1:仅位置
self._xyz = self.base_xyz + self.deformation_net(self.base_xyz, t)
# 选项2:旋转+缩放也偏移
self._rotation = self.base_rotation + delta_rotation(t)
self._scaling = self.base_scaling  scale_factor(t)

2.5 Appearance Embedding → 逐高斯外观 NeRF:每图一个向量 3DGS:每高斯存调制特征

class AppearanceGaussians(nn.Module):
    ...
数据来源ClawHub ↗ · 中文优化:龙虾技能库