nerfstudio-project / nerfstudio

A collaboration friendly studio for NeRFs
https://docs.nerf.studio
Apache License 2.0
8.87k stars 1.18k forks source link

Ability to disable Viser during training a nerf #3259

Open AruniRC opened 3 days ago

AruniRC commented 3 days ago

Is your feature request related to a problem? Please describe. I am unable to turn off Viser during training a nerf using Nerfstudio.

Describe the solution you'd like In some applications, for example if I am trying to build something on top of Nerfstudio, we may not want to use Viser but some custom tool for the viewer. Being able to easily turn off Viser during model training via the Python API at least would help here.

Describe alternatives you've considered I have tried various settings for "vis" and "viewer" options in the trainer, but these were not successful workarounds. Other than majorly editing the existing Nerfstudio codebase, I did not see any clean way to disable Viser from running.

Additional context

Code snippet below of what I tried:

from nerfstudio.configs.method_configs import method_configs
from nerfstudio.scripts.train import main
from pathlib import Path

# Create default training config for the nerfacto method
cfg = method_configs["nerfacto"]

# Specify where the pre-processed data is saved (must contain 'transforms.json')
cfg.data = Path("processed_data_folder")

# attempt to  turn off in-browser viewer (Viser) ?
# cfg.vis = None        # no effect!
# cfg.viewer = None  # training fails with error!

# begin training!
main(cfg)
brentyi commented 3 days ago

Yeah, this isn't supported at the moment without turning on tensorboard, wandb, etc. Some relevant lines in the code:

https://github.com/nerfstudio-project/nerfstudio/blob/9b3cbc79bf239eb3c69e7c288632aab02c4f0bb1/nerfstudio/engine/trainer.py#L178-L191

https://github.com/nerfstudio-project/nerfstudio/blob/9b3cbc79bf239eb3c69e7c288632aab02c4f0bb1/nerfstudio/configs/experiment_config.py#L83-L85

https://github.com/nerfstudio-project/nerfstudio/blob/9b3cbc79bf239eb3c69e7c288632aab02c4f0bb1/nerfstudio/configs/experiment_config.py#L66-L69

It seems like we could just add "none" as an option to the literal type for vis.

AruniRC commented 1 day ago

Hi @brentyi ,

your suggestion worked.

Adding "none" as another option to the vis Literal type, and then setting vis to "none" in the config, turns off viser (or any other visualization that gets sent to a port).

Would you consider adding this as an enhancement, since its fairly minor?

AruniRC commented 1 day ago

Moreover, currently Nerfstudio appears to enable evaluation iterations on datasets only when the vis is set to tensorboard, wandb or comet combinations. Is there any way to have "none" for the vis (to disable the in-browser viewer or logger), but still show the evaluation loss or PSNR on the console or simple text logs?