–pipeline.model.sdf-field.inside-outside True
运行命令:
ns-train neus --pipeline.model.sdf-field.inside-outside False sdfstudio-data --data DATA_PATH
Neus 参数解析包括其他methods (volsdf、neus 和monodepth ) 的Dataparser 的指令主要是在 sdfstudio_dataparser.py 文件中:
不同的SDF 方法需要的Input 不一样,他们的input 读取都被集成在了_generate_dataparser_outputs 函数里面。 针对不同的 surface reconstruction 方法设置了一些参数:
Neus 中主要 用到的rgb图 和位姿矩阵T。没有用到的是normal图和depth 图像.
需要注意的是Neus 中的 rgb源图像是1200*1600 的图像,但是对应的 noraml map 和 depth map 都是 384×384 的图像。且生成的Camera 的 height and width 都是384.
cameras = Cameras(
fx=fx,
fy=fy,
cx=cx, ##198
cy=cy, ## 198
height=height,
width=width,
camera_to_worlds=camera_to_worlds[:, :3, :4],
camera_type=CameraType.PERSPECTIVE,
)
所以dtu 的图像肯定在之后进行了 crop 且和 normal 图像还有depth 图像对齐。
创立了 traindataset 之后,读取了位姿和imgae_filename 但是还没有读取图像变成tensor。
self.train_dataset = self.create_train_dataset()
self.eval_dataset = self.create_eval_dataset()
GeneralizedDataset 函数可以读取图像:
其中track 函数,相当于tqdm 一样的python 库,可以显示读取图像的进度。
Neus 在sdfstudio 中读取的图像并非是dtu 中的 1200*1600 的图像,而是其经过处理之后的384×384 的图像。
Neus 在读取datasets 的时候,读取rgb 图像;c2w 位姿,相机的一些参数就可以了。
neus 运行在sdfstudio 的命令:
先指定需要训练的GPU 的编号:
export CUDA_VISIBLE_DEVICES=0
如果在pycharm 中,把 CUDA_VISIBLE_DEVICES=0 加到前面 Environment variables
需要使用预加载的训练权重参数 : –trainer.load-dir {None}|PATH]
ns-train neus --trainer.load-dir outputs/datasets-kitti360_Neus/neus/2023-01-30_160720/sdfstudio_models/ --pipeline.model.sdf-field.inside-outside False --viewer.skip_openrelay True sdfstudio-data --data datasets/kitti360_Neus/
在sdfstudio 中,trainset 和 Valset 是同一批数据,为了验证在新视角的synthetic viewpoint 的合成质量,需要修改sdfstudio_dataparser.py 文件,将图像分成trainset 和 valset.
Code 如下所示:
num_images = len(image_filenames)
num_train_images = math.ceil(num_images * self.config.train_split_percentage)
num_eval_images = num_images - num_train_images
i_all = np.arange(num_images)
i_train = np.linspace(
0, num_images - 1, num_train_images, dtype=int
) # equally spaced training images starting and ending at 0 and num_images-1
i_eval = np.setdiff1d(i_all, i_train) # eval images are the remaining images
assert len(i_eval) == num_eval_images
if split == "train":
indices = i_train
elif split in ["val", "test"]:
indices = i_eval
else:
raise ValueError(f"Unknown dataparser split {split}")