当前位置: 首页 > ops >正文

ubuntu18.04安装nerfstudio

ubuntu18.04安装nerfstudio

nerfstudio提供了一个简单的API,可以简化创建、训练和可视化NeRF的端到端过程。该库通过模块化每个组件来支持可解释的NeRF实现。nerfstudio源码地址: https://github.com/nerfstudio-project/nerfstudio , 通过模块化集成了多个NeRF扩展的实现,持续更新,带界面,license为Apache-2.0。

  目前已支持的方法:(1).Nerfacto: facto NeRF,将专注于质量的模块和专注于更快渲染的模块相结合;(2).NeRF:《Representing Scenes as Neural Radiance Fields for View Synthesis》;(3).Instant NGP:《Instant Neural Graphics Primitives with a Multiresolution Hash Encoding》;(4).Mipnerf: 《A Multiscale Representation for Anti-Aliasing Neural Radiance Fields》;(5).NerfW: 《Neural Radiance Fields for Unconstrained Photo Collections》;(6).Semantic NeRF: 《In-Place Scene Labelling and Understanding with Implicit Scene Representation》.

1.安装Anaconda、cuda、cudnn、cmake、gcc、g++

网上有很多教程,这里不再赘述
//------------------------------------------------------------------------------//

安装号cuda之后
(1)在自己的环境下打开.bashrc文件,可使用vim ~/.bashrc命令;

vim ~/.bashrc
或者
gedit ~/.bashrc

(2)将下面几段代码粘贴进去,这里可建立软连接,可以通过修改文件中的路径切换cuda版本。

export PATH="$PATH:/usr/local/cuda-11.3/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-11.3/lib64/"
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/cuda-11.3/lib64"

(3)然后激活一下

source ~/.bashrc

2.新建环境

conda create --name nerfstudio -y python=3.8
conda activate nerfstudio
python -m pip install --upgrade pip

3.安装pytorch

pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 -f https://download.pytorch.org/whl/torch_stable.html

4.安装 tinycudann(这里面有很多坑!!)

这个是官方给出来的命令,不建议用,存在很多问题

pip install ninja git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch

按照这些命令行安装

# 安装git
sudo apt-get install build-essential git
# 下载仓库
git clone --recursive https://github.com/nvlabs/tiny-cuda-nn
cd tiny-cuda-nn
# 还有两个包要自己手动安装
pip install fmt
pip install cutlass

编译(这一步可能会发生错误)

# 编译,如果没安装cmake的话需要安装cmake,至少3.18版本
cmake . -B build
cmake --build build --config RelWithDebInfo -j

编译错误
用这个命令直接指定到你要用的cuda,就解决了。

cmake -DCMAKE_CUDA_COMPILER=/usr/local/cuda-11.7/bin/nvcc . -B build
cmake --build build --config RelWithDebInfo -j

如果你之前已经build失败过,需要先删除掉你编译过的东西。

rm -rf build

安装tinycudann

# 安装tinycudann
cd bindings/torch
python setup.py install 
或者
python3 setup.py install

验证安装(没有报错说明安装成功)

python
import tinycudann

5.安装nerfstudio

官方文档有两种安装方式,强烈推荐使用第二种,第一种会下载torch2.0.0,后面各种报错。
第一种,使用pip直接安装(不建议使用)

pip install nerfstudio

第二种,先下载github仓库,本地安装

# 下载github仓库
git clone https://github.com/nerfstudio-project/nerfstudio.git
# 进入文件目录
cd nerfstudio
# 安装nerfstudio
pip install --upgrade pip setuptools
pip install -e .

这里安装的时候应该会默认下载torch1.13.1,后面跑代码的时候依然报错,需要重新下载torch1.12.1,使用如下命令重新安装pytorch

pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 -f https://download.pytorch.org/whl/torch_stable.html

6.跑案例

从官方数据集下载person测试数据集,解压压缩包,并将其拷贝到nerfstudio的data/nerfstudio目录下(自己创建)。
执行以下命令:

ns-train nerfacto --data data/nerfstudio/person --vis viewer --max-num-iterations 50000

开始训练(需要点时间)
请添加图片描述
如果出现只有图片但是没有画面的情况,可以执行这个命令(等个几十秒就能看到):

ns-train nerfacto --data data/nerfstudio/person --vis viewer --max-num-iterations 50000 --viewer.skip-openrelay True

在这里插入图片描述

7.训练自己的数据集

多相机数据集
看这里的Metashapehttps://docs.nerf.studio/en/latest/quickstart/custom_dataset.html
数据集:

ns-process-data metashape --data data/nerfstudio/mouse/mouse --xml data/nerfstudio/mouse/mouse_save/mouse.xml --output-dir outputs/mouse/

训练:

ns-train nerfacto --data outputs/mouse/ --viewer.skip-openrelay True --pipeline.model.predict-normals True
ns-train instant-ngp --output-dir outputs/mouse/ --viewer.skip-openrelay True --pipeline.model.predict-normals True

视频

ns-render --load-config outputs/outputs-mouse/nerfacto/2023-09-14_195319/config.yml --traj filename --camera-path-filename outputs/mouse/camera_paths/2023-09-14_195319.json --output-path renders/mouse/2023-09-14_195319.mp4

点云

ns-export pointcloud --load-config outputs/outputs-mouse/nerfacto/2023-09-14_195319/config.yml --output-dir exports/pcd/ --num-points 1000000 --remove-outliers True --estimate-normals False --use-bounding-box True --bounding-box-min -1 -1 -1 --bounding-box-max 1 1 1

mesh

ns-export poisson --load-config outputs/outputs-mouse/nerfacto/2023-09-14_195319/config.yml --output-dir exports/mesh/ --target-num-faces 50000 --num-pixels-per-side 2048 --normal-output-name normals --num-points 1000000 --remove-outliers True --use-bounding-box True --bounding-box-min -1 -1 -1 --bounding-box-max 1 1 1

8.用colmap&&nerfacto

1.colmap数据集准备

ns-process-data {images, video} --data {DATA_PATH} --output-dir {PROCESSED_DATA_DIR}
ns-process-data images --data data/nerfstudio/2b/ --output-dir outputs/2b/
ns-process-data images --data data/nerfstudio/golf/ --output-dir outputs/golf/

2.训练

ns-train nerfacto --data {PROCESSED_DATA_DIR}
ns-train nerfacto --data outputs/2b/ --viewer.skip-openrelay True --pipeline.model.predict-normals True
ns-train nerfacto --data outputs/golf/ --viewer.skip-openrelay True --pipeline.model.predict-normals True

3.mesh

ns-export poisson --load-config outputs/outputs-2b/nerfacto/2023-09-12_205620/config.yml --output-dir exports/mesh/ --target-num-faces 50000 --num-pixels-per-side 2048 --normal-output-name normals --num-points 1000000 --remove-outliers True --use-bounding-box True --bounding-box-min -1 -1 -1 --bounding-box-max 1 1 1

4.点云

ns-export pointcloud --load-config outputs/outputs-2b/nerfacto/2023-09-12_205620/config.yml --output-dir exports/pcd/ --num-points 1000000 --remove-outliers True --estimate-normals False --use-bounding-box True --bounding-box-min -1 -1 -1 --bounding-box-max 1 1 1

5.視頻

ns-render --load-config outputs/outputs-2b/nerfacto/2023-09-13_143358/config.yml --traj filename --camera-path-filename outputs/2b/camera_paths/2023-09-13_143358.json --output-path renders/2b/2023-09-13_143358.mp4

9.用colmap&&instant-ngp

1.colmap数据集准备

ns-process-data {images, video} --data {DATA_PATH} --output-dir {PROCESSED_DATA_DIR}
ns-process-data images --data data/nerfstudio/2b/ --output-dir outputs/2b/
ns-process-data images --data data/nerfstudio/golf/ --output-dir outputs/golf/

2.将生成的文件放transforms.json和images(你要训练的文件)放在data/nerfstudio/poster下
在这里插入图片描述
3.训练

ns-train nerfacto --data {PROCESSED_DATA_DIR}
ns-train instant-ngp --output-dir outputs/2b

10.psnr、ssim、lipips

运行命令行

 ns-train nerfacto --data data/nerfstudio/person --vis tensorboard --viewer.skip-openrelay True --steps-per-eval-batch 50 --steps-per-eval-image 50 --steps-per-eval-all-images 200 --max-num-iterations 201 --viewer.websocket-port 7008
http://www.xdnf.cn/news/7547.html

相关文章:

  • DataBinding深度解析:从编译原理到抖音级性能优化
  • window 显示驱动开发-准备 DMA 缓冲区
  • 关于 APK 反编译与重构工具集
  • 【HTML-3】HTML 中的水平线与换行:基础元素详解
  • React表单开发的瑞士军刀:Formik与Yup实战指南
  • [luogu12541] [APIO2025] Hack! - 交互 - 构造 - 数论 - BSGS
  • 线上jvm假死问题排查
  • 内存分页法
  • 前端小demo项目实战<京东秒杀Tab栏切换、进度条控制和成绩管理表单>
  • 代码随想录算法训练营 Day52 图论Ⅲ 岛屿问题Ⅱ 面积 孤岛 水流 造岛
  • 软考中级-软件设计师 UML图详解( 类图,对象图,用例图,序列图,通信图,状态图,活动图,构件图,部署图)
  • 【每天一个MCP】【记录向】:准备工作,创建github项目
  • 武汉副市长李湛莅临指导 珈和展会精彩亮相引《武汉电视台》深度报道 以硬核科技赋能农业强链新范式获政府媒体“双重点赞”
  • 【老马】流程引擎(Process Engine)概览
  • LLM | 论文精读 | NAACL 2025 | Clarify When Necessary:教语言模型何时该“问一句”再答!
  • HarmonyOS5云服务技术分享--认证文档问题
  • 清华大学无人机城市空间导航探索!CityNavAgent:基于层次语义规划与全局记忆的空中视觉语言导航
  • 开疆智能Profinet转ModbusTCP网关连接BORUNTE伯朗特系统配置案例
  • Django基础(一)MVT 模式与 Django 框架
  • 北斗导航 | 基于matlab的多波束技术的卫星通信系统性能仿真
  • python自学笔记5 函数
  • 正则表达式进阶(三):递归模式与条件匹配的艺术
  • 【北邮通信系统建模与仿真simulink笔记】(1)主要用到的模块库介绍
  • 【MySQL】04.数据类型
  • 计算机组成与体系结构:RAM(随机存取存储器)
  • c/c++的opencv均值模糊
  • 微软账户无密码化的取证影响
  • 基于大模型预测的闭合性髌骨骨折诊疗全流程研究报告
  • 【信息系统项目管理师】第11章:项目成本管理 - 32个经典题目及详解
  • Windows系统下MySQL 8.4.5压缩包安装详细教程