4
0
mirror of https://github.com/nerfstudio-project/nerfstudio.git synced 2026-11-11 02:24:38 +08:00
nerfstudio/tests/test_train.py
Brent Yi 6a7c8820b8
Viewer backend refactor (#1702)
* Copy in `viser` communication infrastructure

* Update background image

* Add build directory to fix viser HTTP server
May want to remove these later

* Copy in `viser` communication infrastructure

* Update background image

* Pass dataset vis using viser

* initial impl of ViewerParameter

* idk what i did but brent and matt know

* Suppress eslint typescript warnings

* implement ViewerElement base class, then ViewerButton, ViewerSlider, etc

* client -> server message setup

* multi folder stuff

* Stream controls over viser

* import

* add types to viewer_param.py

* Move another message to viser

* Update folder color

* Use non throttled messages

* multiple folders works

* Cleanup, more porting

* starting impl of control panel in viser

* More porting

* scenebox to viser

* Cleanup

* Fix render updates

* More cleanup, docs, typing

* start control_panel.py

* set_hidden logic but not merged in

* control_panel replicates behavior of existing control panel (visually), except for setting the list of output options. not yet integrated with viewer_utils.py for logic flow. also implemented set_disabled and set_hidden in javscript/ViewerElement side

* Remove some original leva components

* add some train util logic, attempt set_value, doesn't work on javascript side fully yet (value updates but not slider visually

* bye zmq

* missing call to decoder

* 'gui_set' works properly, control panel now replicates behavior of original

* remove print

* Fix status viewer message

* More cleanup

* support set_options in dropdown

* hiding buttons works correctly

* fix set_options, switch from cur_value to get_value()

* Fix slowdown

* output options

* colormap logic converted

* add handle to cb_hook

* fix some lambda bugs

* cleanup

* Save checkpoint logic readded

* Cleanup and minor fixes

* snappier ui

* Refactoring

* Fix state update bugs

* Bug fixes

* Write less to redux

* added comments to reducer code

* Render state machine (#1727)

* state machine works, but train step throttling not implemented

* more step logic, cleanup

* remove random try catcH

* mutex logic for render

* Update lock logic

* types and docs

* added some state machine logic to help rerenders

* merge

---------

Co-authored-by: Justin <justin.g.kerr@gmail.com>

* Refactor and cleanup

* More cleanup and docs

* docstring to gui_utils

* docstrings, rename viewer_param.py to viewer_elements.py

* Fix viewer, remove bridge stuff

* Render on connect

* Fix lint errors

* More eslint fixes

* render_freq logic

* better rerender logic for crop

* More cleanup

* Purge

* Cleanup

* Lint fixes

* Fix cache

* better parsing logic

* Fix infinite test

* More cleanup

* typo

* Update webdocs

* Update docs

* rerender on custom hooks

* add more docs

* Use shared utilities in `viser.infra`

* rework callback to use elements instead of handles

* Fix ESlint errors

* change naming of handle to element, add setter for value

* cleanup

---------

Co-authored-by: Matt Tancik <mattt4001@gmail.com>
Co-authored-by: Justin <justin.g.kerr@gmail.com>
Co-authored-by: Ethan Weber <eweb0124@gmail.com>
Co-authored-by: Matthew Tancik <tancik@berkeley.edu>
2023-04-14 14:53:10 -07:00

85 lines
2.5 KiB
Python

# pylint: disable=protected-access
"""
Default test to make sure train runs
"""
from __future__ import annotations
from pathlib import Path
import pytest
from nerfstudio.configs.method_configs import method_configs
from nerfstudio.data.dataparsers.blender_dataparser import BlenderDataParserConfig
from nerfstudio.data.dataparsers.minimal_dataparser import MinimalDataParserConfig
from nerfstudio.engine.trainer import TrainerConfig
from scripts.train import train_loop
BLACKLIST = [
"base",
"semantic-nerfw",
"instant-ngp",
"instant-ngp-bounded",
"nerfacto",
"nerfacto-big",
"volinga",
"phototourism",
"depth-nerfacto",
"nerfplayer-ngp",
"nerfplayer-nerfacto",
"neus",
"neus-facto",
]
def set_reduced_config(config: TrainerConfig):
"""Reducing the config settings to speedup test"""
config.machine.num_gpus = 0
config.max_num_iterations = 2
# reduce dataset factors; set dataset to test
config.pipeline.datamanager.dataparser = BlenderDataParserConfig(data=Path("tests/data/lego_test"))
config.pipeline.datamanager.train_num_images_to_sample_from = 1
config.pipeline.datamanager.train_num_rays_per_batch = 4
# use tensorboard logging instead of wandb
config.vis = "tensorboard"
config.logging.relative_log_dir = Path("/tmp/")
# reduce model factors
if hasattr(config.pipeline.model, "num_coarse_samples"):
config.pipeline.model.num_coarse_samples = 4
if hasattr(config.pipeline.model, "num_importance_samples"):
config.pipeline.model.num_importance_samples = 4
# remove viewer
config.viewer.quit_on_train_completion = True
return config
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
def test_train():
"""test run train script works properly"""
all_config_names = method_configs.keys()
for config_name in all_config_names:
if config_name in BLACKLIST:
print("skipping", config_name)
continue
print(f"testing run for: {config_name}")
config = method_configs[config_name]
config = set_reduced_config(config)
train_loop(local_rank=0, world_size=0, config=config)
def test_simple_io():
"""test to check minimal data IO works correctly"""
config = method_configs["vanilla-nerf"]
config.pipeline.datamanager.dataparser = MinimalDataParserConfig(data=Path("tests/data/minimal_parser"))
config = set_reduced_config(config)
train_loop(local_rank=0, world_size=0, config=config)
if __name__ == "__main__":
test_train()
test_simple_io()