在Windows下安装Instant-ngp相对简单。
![](https://img.haomeiwen.com/i12824314/d3d37a2bebb8ac09.png)
然后可以在根目录文件夹直接点击exe文件夹,即可运行instant-ngp。此时是一个黑色的屏幕,是一个正常的输出结果。
1、运行示例代码
我们可以找到./data/nerf/fox/将fox文件夹按住然后拖动到instant-ngp的界面中,就能够将其作为输入,进行nerf模型的训练了。在几秒钟后,我们就能够看到输出的结果了。
![](https://img.haomeiwen.com/i12824314/77bf759bea32e4cb.png)
然而instant-ngp接受的输入是一个nerf数据格式的数据集,里面需要包含两个数据,第一个是images文件夹,这包含的是不同位姿下的2D图像。
点击mesh it 就能够输出mesh的图像,然后点击save it就能够将其保存在指定目录中。
![](https://img.haomeiwen.com/i12824314/f692930031b2001f.png)
保存好的模型可以用mesh打开。
![](https://img.haomeiwen.com/i12824314/db47b47e725ab0d0.png)
2、构建自己的数据集
第一步:准备环境和数据,可以是一段视频或者是一些图片
我们在某一个目录下创建一个文件夹用来存放这个视屏或者图片,例如:我在test文件夹下,放入了test.mp4;
pip install -r requirements.txt
第二步:****使用instant-ngp自带的脚本去进行位姿恢复
python ./scripts/colmap2nerf.py --video_in ./test/test.mp4 --video_fps 2 --run_colmap --aabb_scale 32
其中video_fps设置的是,每一秒截取多少帧,我们可以根据视频的长度,大概能够估计会产生多少张图片
第三步:切换到test文件夹下,进行特征提取和特征匹配将colmap数据格式转换为nerf数据格式
python ../scripts/colmap2nerf.py --colmap_matcher exhaustive --run_colmap --aabb_scale 32
第四步:切换到根目录下,运行instant-ngp 进行nerf模型的训练和nerf模型转3D模型的输出
instant-ngp ./test
输出结果:(我家狗doge)
![](https://img.haomeiwen.com/i12824314/f8b0ee6f8985e561.png)
由于相机不好,狗子在动,所以并不清晰。但其实ngp建模还是很清晰的。
GitHub 链接:NVlabs/instant-ngp: Instant neural graphics primitives: lightning fast NeRF and more (github.com)
构建独立数据集的视频教学:https://www.youtube.com/watch?v=3TWxO1PftMc
构建自己数据集的文档:NVlabs/instant-ngp: Instant neural graphics primitives: lightning fast NeRF and more (github.com)
ngp的各个实现版本列表
- 官方: https://github.com/NVlabs/instant-ngp
- torch-ngp: https://github.com/ashawkey/torch-ngp
- ngp_pl: https://github.com/kwea123/ngp_pl PyTorch+CUDA trained with pytorch-lightning.
- JNeRF: https://github.com/Jittor/JNeRF An NeRF benchmark based on Jittor.
- HashNeRF-pytorch:https://github.com/yashbhalgat/HashNeRF-pytorch A pure PyTorch implementation.
网友评论