CVPR--I2SDF--Windows复现

CVPR–I2SDF–Windows复现

作为今年新出的基于NeRF的CVPR文章,I2SDF在室内场景重建这一块的效果确实惊艳!!!

在看完

之后,瞬间就想对其进行复现,但是一搜,网上在windows上复现的博客还没有,这里我就先替大家踩坑了。

Windows进行复现:

一:拉取源码

地址:

这一步我就不多说了,做这行的要是连下载源码都不会的话,不不用看这篇博客了。

二:下载数据集

地址:

下载速度有点慢,需要开个梯子。下载下来后,解压到文件的data目录下,在data目录下新建一个目录,名字叫做synthetic。

在这里插入图片描述

将数据集全部解压到synthetic里面,并在config目录下中的synthetic.yml配置文件中添加数据集路径地址。

在这里插入图片描述

三:配置环境

conda env create -f environment.yml
conda activate i2sdf

这里不得不说,i2sdf的环境还是比较好配的,只要网络够快,torch和cuda匹配,基本上大差不差!

具体的细节,这里就不做多赘述。

四:开始运行

github上提供了运行脚本:

训练:

python main_recon.py --conf config/<config_file>.yml --scan_id <scan_id> -d <gpu_id> -v <version>

这里的d为gpu的id,v为版本号,应该是作者为了区别多次训练结果用的,可以随意填写。这个scan_id就有点东西了,作者也没给出解释,在看了源码之后发现其为训练数据集后的编号!!!

在这里插入图片描述

也就是你要训练那个数据集,就去看他数据集后面的数字为多少,这里我使用的是31。

我的电脑配置为i9-13th,GTX4080笔记本,显存12G,将synthetic.yml配置文件中的batch和一些可选的超参数降低,我的显存刚刚好跑满。实测12G够用!!!

有一点不舒服的是,在pycharm中训练的时候看不到进度条!!!但是在cdm中进行训练可以看到,作者写了tensorboard的代码,在训练过程中,可以通过访问tensorboard进行观察其训练状态。

在这里插入图片描述

五:测试

python main_recon.py --conf config/<config_file>.yml --scan_id <scan_id> -d <gpu_id> -v <version> --test [--is_val] [--full]

这里对图片进行单纯的对比测试,生成对比图。

在这里插入图片描述

--conf config/synthetic.yml --scan_id 31 -d 0 -v 1 --test --test_mode interpolate --inter_id 0 50 -f

这里对图片进行视频生成,这一步会进行下采样,导致图片的分辨率再次折半,所以在运行这个脚本之前,可以将synthetic.yml中的downsample修改为1。

在这里插入图片描述

这一步在生成完图片之后,一直会报一个错误:

config=/d/bld/ffmpeg_1685720330394/_build_env/Library/bin/pkg-config
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
[image2 @ 000001E2C208A400] Pattern type 'glob' was selected but globbing is not supported by this libavformat build

在查阅了资料后发现,Windows下不支持在FFmpeg.input中使用glob参数进行通配。因此,我自己写了脚本对其进行替换。

因为这一步的图片是可以正常生成的,因此在生成了图片之后,使用一下代码可以进行视频的生成:


import subprocess
import glob
import os
frame_dir = "D:\\DeepLearn\\NeRF\\i2-sdf-main\\exps\\synthetic_31\\version_1\\eval\\interpolate\\0000_0050"
normal_fdir = "D:\\DeepLearn\\NeRF\\i2-sdf-main\\exps\\synthetic_31\\version_1\\eval\\interpolate\\0000_0050_normal"
os.chdir(frame_dir)
filenames = glob.glob('*.png')
path = os.path.abspath(frame_dir).replace("\\", "/")
print(path)
duration = 0.05

print(os.getcwd())
with open("ffmpeg_input.txt", "wb") as outfile:
    for filename in filenames:
        outfile.write(f"file '{path}/{filename}'\n".encode())
        outfile.write(f"duration {duration}\n".encode())
command_line = f"ffmpeg -r 20 -f concat -safe 0 -i ffmpeg_input.txt -s 450x304 -c:v libx265 -pix_fmt yuv420p {frame_dir}\out.mp4"
print(command_line)

pipe = subprocess.Popen(command_line, shell=True, stdout=subprocess.PIPE).stdout
output = pipe.read().decode()
pipe.close()

os.chdir(normal_fdir)
filenames = glob.glob('*.png')
path = os.path.abspath(normal_fdir).replace("\\", "/")
print(path)
duration = 0.05
print(os.getcwd())
with open("ffmpeg_input.txt", "wb") as outfile:
    for filename in filenames:
        outfile.write(f"file '{path}/{filename}'\n".encode())
        outfile.write(f"duration {duration}\n".encode())
command_line = f"ffmpeg -r 20 -f concat -safe 0 -i ffmpeg_input.txt -s 450x304 -c:v libx265 -pix_fmt yuv420p {normal_fdir}\out.mp4"
print(command_line)
pipe = subprocess.Popen(command_line, shell=True, stdout=subprocess.PIPE).stdout
output = pipe.read().decode()
pipe.close()

这段代码单独运行时没有问题,正常生成,但是将其添加到源码中的recon.py的284行的def test_epoch_end(self, outputs):的时候,出现了一个bug,大概意思就是跳转不到深度图的路径中,这个bug暂时可以通过手动运行以上代码解决,所以这里就不过多进行处理,要是有想法的小伙伴解决了,可以加我微信私聊,18570266090。欢迎进行技术交流。

在这里插入图片描述

到这,差不多就结束了!感谢大家的观看,如有不对的地方,谢谢指正,本人也还在学习当中。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值