目录
🧱 安装 Detectron2(建议从源码安装,避免运行 colmap2nerf.py 报错)
📦 下载适配 GPU 的 Instant-NGP 可执行程序
🔧 个人环境配置
-
操作系统:Windows 10
-
GPU:NVIDIA RTX 3000 / 4000 系列
-
Conda 环境名称:
gsplat
-
Python:3.8
-
PyTorch:2.1.0 + cu121
-
CUDA:12.1
-
IDE:PyCharm
📌 项目地址
📥 克隆 Instant-NGP 仓库
git clone --recursive https://github.com/nvlabs/instant-ngp
cd instant-ngp
🧱 安装 Detectron2(建议从源码安装,避免运行 colmap2nerf.py 报错)
我这边选择从源码安装 Detectron2,保证后续 colmap2nerf.py
能正常运行:
git clone https://github.com/facebookresearch/detectron2.git
cd detectron2
pip install -e .
cd .. # 回退
📦 下载适配 GPU 的 Instant-NGP 可执行程序
根据我的显卡(RTX 3000 / 4000 系列),我下载的是:Instant-NGP-for-RTX-3000-and-4000。下载后请将该文件夹解压并放入 instant-ngp
根目录下(与 scripts/
同级)。
- RTX 5000 series and other Blackwell cards
- RTX 3000 & 4000 series, RTX A4000–A6000, and other Ampere & Ada cards
- RTX 2000 series, Titan RTX, Quadro RTX 4000–8000, and other Turing cards
- GTX 1000 series, Titan Xp, Quadro P1000–P6000, and other Pascal cards
🗂️ 数据准备结构说明
我使用 COLMAP 处理原始图像,生成了 SfM 位姿信息和图像。将以下两个文件夹放入 instant-ngp/scripts/
目录下:
scripts/
├── colmap_text/ # COLMAP 输出的相机和点云信息
└── images/ # 原始图像
⚠️ 注意事项:
-
建议文件夹命名使用
colmap_text
和images
-
打开
scripts/colmap2nerf.py
文件,查找图像路径拼接语句,删除路径前缀"./"
,避免训练时找不到图像
![]() | ![]() |
![]() |
🔄 执行转换:生成 transforms.json 文件
进入 scripts/
目录,运行转换脚本:
cd scripts
python colmap2nerf.py --images images --text colmap_text
执行成功后会在当前目录下生成 transforms.json
文件。
🚀 启动 Instant-NGP 训练
cd .. # 回到 instant-ngp 根目录
cd Instant-NGP-for-RTX-3000-and-4000
instant-ngp.exe --scene E:\3DReconstruction\instant-ngp\scripts\transforms.json
📌 建议使用绝对路径,否则可执行程序可能无法正确加载数据。
📌 欢迎点赞收藏、留言交流。我将持续更新本教程的踩坑经验和进阶技巧。如果你在运行过程中遇到问题,也欢迎评论告诉我~