嘉兴网站搜索优化,公司网站管理图片,网站怎么创建内容,网站语言版本【三维重建】【深度学习】windows10下instant-nsr-pl代码Pytorch实现 提示:基于 Instant-NGP 和 Pytorch-Lightning 框架的神经表面重建 文章目录 【三维重建】【深度学习】windows10下instant-nsr-pl代码Pytorch实现前言instant-nsr-pl模型运行下载源码并安装环境训练instant-…【三维重建】【深度学习】windows10下instant-nsr-pl代码Pytorch实现 提示:基于 Instant-NGP 和 Pytorch-Lightning 框架的神经表面重建 文章目录 【三维重建】【深度学习】windows10下instant-nsr-pl代码Pytorch实现前言instant-nsr-pl模型运行下载源码并安装环境训练instant-NeuS可能出现的问题 总结 前言
NeRF是由加利福尼亚大学伯克利分校的Mildenhall, Beni等人在《NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis【ECCV 2020】》【论文地址】一文中提出了一种5D的神经辐射场来作为复杂场景的隐式表示其输⼊稀疏的多⻆度带pose的图像训练得到⼀个神经辐射场模型。简单来说就是通过输入同一场景不同视角下的二维图片和相机位姿对场景进行三维隐式建模并通过体素渲染方程实现了合成任意新视角下的场景图片。
NeuS是由香港大学的Wang, P等人在《NeuS: Learning Neural Implicit Surfaces by Volume Rendering for Multi-view Reconstruction【NeurIPS 2021】》【论文地址】一文中提出了一种新的神经表面重建方法用于从2D图像输入中高保真地重建对象和场景。简单来说提出了一种新的一阶近似无偏差的公式从而即使没有掩模监督也能进行更精确的表面重建。
在详细解析instant-nsr-pl网络之前首要任务是明白原始NeRF【Pytorch-demo】和NeuS【Pytorch-demo】的原理和代码解析并完成模型训练和测试工作展开后续工作才有意义。 instant-nsr-pl模型运行
下载源码并安装环境
在win10环境下装anaconda环境方便搭建专用于instant-nsr-pl模型的虚拟环境。 【pytorch代码原始参考教程】 【pytorch代码推荐参考教程(Windows下)】 安装GPU版本的pytorch教程pytorch-gpu版本需要根据个人计算机去安装相应版本。 # 创建虚拟环境
conda create -n instant-nsr-pl python3.8
# 查看新环境是否安装成功
conda env list
# 激活环境
activate instant-nsr-pl
# windows一定要通过网站直接下载
# 下载githup源代码到合适文件夹,并cd到代码文件夹内(科学上网)
git clone https://github.com/bennyguo/instant-nsr-pl.git
# 具体看个人下载的位置xxxxx/instant-nsr-pl
cd instant-nsr-pl
# 安装pytorch包(pytorch建议小于2.0)
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
# 通过清华源,安装其他包
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt安装tiny-cuda-nn比较特殊,需要安装vs2019或者vs2022注意:需要管理员方式打开x64 Native Tools Command Prompt for VS 2019执行指令不要搞混成x86的会报奇怪的错误
# 个人将tiny-cuda-nn下载在xxxxx/instant-nsr-pl的目录下
cd instant-nsr-pl
git clone --recursive https://github.com/nvlabs/tiny-cuda-nn
cd tiny-cuda-nn/bindings/torch
# 同样需要激活环境
activate instant-nsr-pl
# 安装
python setup.py installgit下载总失败的话可以尝试【tiny-cuda-nn详细教程】方法成功安装tiny-cuda-nn。 注意安装tiny-cuda-nn时候对应的cuda是物理机器上实际安装的cuda版本(环境变量里配置的cuda)不是虚拟环境中的cuda版本。因此假设物理和虚拟的俩个版本cuda不一致即使tiny-cuda-nn安装成功在后续执行训练指令时候也会报错。 # 查看所有安装的包
pip list
conda list最终的安装的所有包。 检查torch版,已经安装torch-gpu版本。
# 查看pytorch版本
import torch
print(torch.__version__)
# 查看cuda版本
print(torch.version.cuda)
# 查看cuda是否可用
print(torch.cuda.is_available())
# 查看可用cuda数量
print(torch.cuda.device_count())训练instant-NeuS
1.下载数据集【谷歌云盘(下载地址)】根据配置文件中数据指定的存放路径在instant-NeuS工程内创建load/文件夹把下载的开源数据解压放到load/文件夹下。 2.训练NeRF
# 训练bmvs_clock数据集
python launch.py --config configs/nerf-blender.yaml --gpu 0 --train dataset.scenelego tagexample训练完成后的结果保存在exp目录中的对应数据文件夹下。 博主将视频转为了GIF方便展示 没有生成obj文件(文件大小为0)。 3.训练NeuS
# 训练bmvs_clock数据集
# 带有mask
python launch.py --config configs/neus-blender.yaml --gpu 0 --train dataset.scenelego tagexample
# 没有mask
python launch.py --config configs/neus-blender.yaml --gpu 0 --train dataset.scenelego tagexample system.loss.lambda_mask0.0带有mask 视角展示(GIF文件也很大超过博客文件所规定的大小)
用meshlab查看模型 没有mask(感觉都差不多) 视角展示 用meshlab查看模型
可能出现的问题 ImportError: cannot import name ‘_compare_version’ from ‘torchmetrics.utilities.imports’ 需要降级一下torchmetrics包 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torchmetrics0.11.1The provided lr scheduler MultiStepLR doesn’t follow PyTorch’s LRScheduler API. You should override the LightningModule.lr_scheduler_step hook with your own logic if you are using a custom LR scheduler. 这是torch 2.0会出现的错误修改(依赖包源码)instant-neus\Lib\site-packages\pytorch_lightning\utilities\types.py内容 LRSchedulerTypeTuple (torch.optim.lr_scheduler._LRScheduler, torch.optim.lr_scheduler.ReduceLROnPlateau)
修改为
LRSchedulerTypeTuple (torch.optim.lr_scheduler.LRScheduler, torch.optim.lr_scheduler.ReduceLROnPlateau)subprocess.CalledProcessError: Command ‘[‘where’, ‘cl’]’ returned non-zero exit status 1. 设置cl.exe环境变量 根据自己的安装路径配置环境 # 在环境变量中Path添加路径(博主的)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64;
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE
# 在环境变量中新建INCLUDE变量再添加(英文分号隔开)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE;
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt;
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um;
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared
# 在环境变量中新建LIB变量再添加(英文分号隔开)
C:\Windows Kits\10\Include\10.0.19041.0\shared
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\ucrt\x64;
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x64在cmd上输入cl验证是否配置成功 前面是提示subprocess.CalledProcessError: Command ‘[‘ninja’, ‘-v’]’ returned non-zero exit status 1. “后面出现ninja: build stopped: subcommand failed.”增大虚拟内存 在系统设置中修改虚拟内存的大小然后重启主机激活 前面是提示“OSError: [WinError 1455] 页面文件太小无法完成操作”同样是增大虚拟内存或者之前增加的虚拟内存不够 总结
尽可能简单、详细的介绍instant-nsr-pl的安装流程以及解决了安装过程中可能存在的问题。后续会根据自己学到的知识结合个人理解讲解instant-NeuS的原理和代码。