Migrate to viser viewer (#2515)

* fix jittering in markdown in viewer beta

* Revert "fix jittering in markdown in viewer beta"

This reverts commit 70ade42e46.

* Migrate to viser viewer

* Fix docs

* print correctly formatted url in banner for viewer beta

* add deprecation warnings to viewer_elements.py

* fix export string scientific notation bug, change .5 to 2.0 sec transition time

---------

Co-authored-by: Justin Kerr <justin.g.kerr@gmail.com>
This commit is contained in:
Matthew TancikandJustin Kerr authored and GitHub committed 2024-01-08 11:40:02 -08:00
1 parent ca9e6c1294
commit 451a70c1f3
92 files changed
+133 -124

No files matched your search

+10 -10
View File
@@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
defaults: defaults:
run: run:
working-directory: ./nerfstudio/viewer/app working-directory: ./nerfstudio/viewer_legacy/app
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@master uses: actions/checkout@master
@@ -22,7 +22,7 @@ jobs:
with: with:
node-version: 17.8.0 node-version: 17.8.0
cache: 'yarn' cache: 'yarn'
cache-dependency-path: ./nerfstudio/viewer/app/yarn.lock cache-dependency-path: ./nerfstudio/viewer_legacy/app/yarn.lock
- name: Install packages - name: Install packages
run: yarn install run: yarn install
@@ -34,7 +34,7 @@ jobs:
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: production-files name: production-files
path: ./nerfstudio/viewer/app/build path: ./nerfstudio/viewer_legacy/app/build
deploy: deploy:
name: Deploy name: Deploy
@@ -53,13 +53,13 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install -r ./nerfstudio/viewer/app/requirements.txt pip install -r ./nerfstudio/viewer_legacy/app/requirements.txt
- name: Download artifact - name: Download artifact
uses: actions/download-artifact@v2 uses: actions/download-artifact@v2
with: with:
name: production-files name: production-files
path: ./nerfstudio/viewer/app/build path: ./nerfstudio/viewer_legacy/app/build
- name: Get branch name (merge) - name: Get branch name (merge)
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
@@ -71,7 +71,7 @@ jobs:
shell: bash shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV
# TODO: detect file or scheme changes of the viewer and only # TODO: detect file or scheme changes of the viewer_legacy and only
# increment the version.txt file when there is a change. # increment the version.txt file when there is a change.
# Update the version.txt code and push to master when things change. # Update the version.txt code and push to master when things change.
# https://github.com/marketplace/actions/changed-files # https://github.com/marketplace/actions/changed-files
@@ -79,7 +79,7 @@ jobs:
# id: changed-files-for-dir1 # id: changed-files-for-dir1
# uses: tj-actions/changed-files@v29.0.3 # uses: tj-actions/changed-files@v29.0.3
# with: # with:
# path: nerfstudio/viewer/app # path: nerfstudio/viewer_legacy/app
# - name: List all added files in dir1 # - name: List all added files in dir1
# run: | # run: |
@@ -88,10 +88,10 @@ jobs:
# done # done
- run: | - run: |
python ./nerfstudio/viewer/app/run_deploy.py \ python ./nerfstudio/viewer_legacy/app/run_deploy.py \
--branch-name ${{ env.BRANCH_NAME }} \ --branch-name ${{ env.BRANCH_NAME }} \
--ssh-key-string "$SSH_KEY" \ --ssh-key-string "$SSH_KEY" \
--local-folder ./nerfstudio/viewer/app/build \ --local-folder ./nerfstudio/viewer_legacy/app/build \
--package-json-filename ./nerfstudio/viewer/app/package.json \ --package-json-filename ./nerfstudio/viewer_legacy/app/package.json \
--increment-version "False" --increment-version "False"
- run: cat ~/.ssh/config - run: cat ~/.ssh/config
+4 -4
View File
@@ -9,10 +9,10 @@ We provide support for custom viewer GUI elements that can be defined in any `nn
## Adding an Element ## Adding an Element
To define a custom element, create an instance of one of the provided classes in `nerfstudio.viewer.server.viewer_elements`, and assign it as a class variable in your `nn.Module`. To define a custom element, create an instance of one of the provided classes in `nerfstudio.viewer.viewer_elements`, and assign it as a class variable in your `nn.Module`.
```python ```python
from nerfstudio.viewer.server.viewer_elements import ViewerNumber from nerfstudio.viewer.viewer_elements import ViewerNumber
class MyClass(nn.Module):#must inherit from nn.Module class MyClass(nn.Module):#must inherit from nn.Module
def __init__(self): def __init__(self):
@@ -20,7 +20,7 @@ class MyClass(nn.Module):#must inherit from nn.Module
self.custom_value = ViewerNumber(name="My Value", default_value=1.0) self.custom_value = ViewerNumber(name="My Value", default_value=1.0)
``` ```
**Element Hierarchy** **Element Hierarchy**
The viewer recursively searches all `nn.Module` children of the base `Pipeline` object, and arranges parameters into folders based on their variable names. The viewer recursively searches all `nn.Module` children of the base `Pipeline` object, and arranges parameters into folders based on their variable names.
For example, a `ViewerElement` defined in `pipeline.model.field` will be in the "Custom/model/field" folder in the GUI. For example, a `ViewerElement` defined in `pipeline.model.field` will be in the "Custom/model/field" folder in the GUI.
**Reading the value** **Reading the value**
@@ -81,7 +81,7 @@ Updating module state while training can have unexpected side effects. It is up
This was created with the following elements: This was created with the following elements:
```python ```python
from nerfstudio.viewer.server.viewer_elements import * from nerfstudio.viewer.viewer_elements import *
class MyModel(Model): class MyModel(Model):
def __init__(self): def __init__(self):
@@ -14,7 +14,7 @@ Just like `ViewerElements`, you can create an instance inside any class which in
and is contained within the `Pipeline` object (for example the `Model`) and is contained within the `Pipeline` object (for example the `Model`)
```python ```python
from nerfstudio.viewer.server.viewer_elements import ViewerControl from nerfstudio.viewer.viewer_elements import ViewerControl
class MyModel(nn.Module): # Must inherit from nn.Module class MyModel(nn.Module): # Must inherit from nn.Module
def __init__(self): def __init__(self):
@@ -25,7 +25,7 @@ class MyModel(nn.Module): # Must inherit from nn.Module
To get the current camera intrinsics and extrinsics, use the `get_camera` function. This returns a `nerfstudio.cameras.cameras.Cameras` object. This object can be used to generate `RayBundles`, retrieve intrinsics and extrinsics, and more. To get the current camera intrinsics and extrinsics, use the `get_camera` function. This returns a `nerfstudio.cameras.cameras.Cameras` object. This object can be used to generate `RayBundles`, retrieve intrinsics and extrinsics, and more.
```python ```python
from nerfstudio.viewer.server.viewer_elements import ViewerControl, ViewerButton from nerfstudio.viewer.viewer_elements import ViewerControl, ViewerButton
class MyModel(nn.Module): # Must inherit from nn.Module class MyModel(nn.Module): # Must inherit from nn.Module
def __init__(self): def __init__(self):
@@ -47,10 +47,10 @@ class MyModel(nn.Module): # Must inherit from nn.Module
``` ```
## Set Camera Properties ## Set Camera Properties
You can set the viewer camera position and FOV from python. You can set the viewer camera position and FOV from python.
To set position, you must define a new camera position as well as a 3D "look at" point which the camera aims towards. To set position, you must define a new camera position as well as a 3D "look at" point which the camera aims towards.
```python ```python
from nerfstudio.viewer.server.viewer_elements import ViewerControl,ViewerButton from nerfstudio.viewer.viewer_elements import ViewerControl,ViewerButton
class MyModel(nn.Module): # Must inherit from nn.Module class MyModel(nn.Module): # Must inherit from nn.Module
def __init__(self): def __init__(self):
@@ -66,7 +66,7 @@ class MyModel(nn.Module): # Must inherit from nn.Module
We forward *single* clicks inside the viewer to the ViewerControl object, which you can use to interact with the scene. To do this, register a callback using `register_click_cb()`. The click is defined to be a ray that starts at the camera origin and passes through the click point on the screen, in world coordinates. We forward *single* clicks inside the viewer to the ViewerControl object, which you can use to interact with the scene. To do this, register a callback using `register_click_cb()`. The click is defined to be a ray that starts at the camera origin and passes through the click point on the screen, in world coordinates.
```python ```python
from nerfstudio.viewer.server.viewer_elements import ViewerControl,ViewerClick from nerfstudio.viewer.viewer_elements import ViewerControl,ViewerClick
class MyModel(nn.Module): # must inherit from nn.Module class MyModel(nn.Module): # must inherit from nn.Module
def __init__(self): def __init__(self):
@@ -89,4 +89,3 @@ You can also use `unregister_click_cb()` to remove callbacks that are no longer
### Thread safety ### Thread safety
Just like `ViewerElement` callbacks, click callbacks are asynchronous to training and can potentially interrupt a call to `get_outputs()`. Just like `ViewerElement` callbacks, click callbacks are asynchronous to training and can potentially interrupt a call to `get_outputs()`.
-1
View File
@@ -161,7 +161,6 @@ This documentation is organized into 3 parts:
| ---------------------------------------------------------- | ---------------------- | | ---------------------------------------------------------- | ---------------------- |
| [Github](https://github.com/nerfstudio-project/nerfstudio) | Official Github Repo | | [Github](https://github.com/nerfstudio-project/nerfstudio) | Official Github Repo |
| [Discord](https://discord.gg/RyVk6w5WWP) | Join Discord Community | | [Discord](https://discord.gg/RyVk6w5WWP) | Join Discord Community |
| [Viewer](https://viewer.nerf.studio/) | Web-based Nerf Viewer |
| [Feedback Form](https://forms.gle/sqN5phJN7LfQVwnP9) | Provide Nerfstudio Feedback | | [Feedback Form](https://forms.gle/sqN5phJN7LfQVwnP9) | Provide Nerfstudio Feedback |
## Sponsors ## Sponsors
+1 -1
View File
@@ -3,6 +3,6 @@
Viewer Viewer
============ ============
.. automodule:: nerfstudio.viewer.server.viewer_elements .. automodule:: nerfstudio.viewer.viewer_elements
:members: :members:
:show-inheritance: :show-inheritance:
+1 -1
View File
@@ -24,7 +24,7 @@ import nerfstudio.utils.poses as pose_utils
from nerfstudio.cameras import camera_utils from nerfstudio.cameras import camera_utils
from nerfstudio.cameras.camera_utils import get_interpolated_poses_many from nerfstudio.cameras.camera_utils import get_interpolated_poses_many
from nerfstudio.cameras.cameras import Cameras, CameraType from nerfstudio.cameras.cameras import Cameras, CameraType
from nerfstudio.viewer.server.utils import three_js_perspective_camera_focal_length from nerfstudio.viewer_legacy.server.utils import three_js_perspective_camera_focal_length
def get_interpolated_camera_path(cameras: Cameras, steps: int, order_poses: bool) -> Cameras: def get_interpolated_camera_path(cameras: Cameras, steps: int, order_poses: bool) -> Cameras:
+7 -7
View File
@@ -69,7 +69,7 @@ class ExperimentConfig(InstantiateConfig):
) )
"""Dictionary of optimizer groups and their schedulers""" """Dictionary of optimizer groups and their schedulers"""
vis: Literal[ vis: Literal[
"viewer", "wandb", "tensorboard", "comet", "viewer+wandb", "viewer+tensorboard", "viewer+comet", "viewer_beta" "viewer", "wandb", "tensorboard", "comet", "viewer+wandb", "viewer+tensorboard", "viewer+comet", "viewer_legacy"
] = "wandb" ] = "wandb"
"""Which visualizer to use.""" """Which visualizer to use."""
data: Optional[Path] = None data: Optional[Path] = None
@@ -81,13 +81,13 @@ class ExperimentConfig(InstantiateConfig):
load_scheduler: bool = True load_scheduler: bool = True
"""Whether to load the scheduler state_dict to resume training, if it exists.""" """Whether to load the scheduler state_dict to resume training, if it exists."""
def is_viewer_enabled(self) -> bool: def is_viewer_legacy_enabled(self) -> bool:
"""Checks if a viewer is enabled.""" """Checks if the legacy viewer is enabled."""
return self.vis in ("viewer", "viewer+wandb", "viewer+tensorboard", "viewer+comet") return "viewer_legacy" == self.vis
def is_viewer_beta_enabled(self) -> bool: def is_viewer_enabled(self) -> bool:
"""Checks if a viewer beta is enabled.""" """Checks if the viewer is enabled."""
return "viewer_beta" == self.vis return self.vis in ("viewer", "viewer+wandb", "viewer+tensorboard", "viewer+comet")
def is_wandb_enabled(self) -> bool: def is_wandb_enabled(self) -> bool:
"""Checks if wandb is enabled.""" """Checks if wandb is enabled."""
+1 -1
View File
@@ -644,7 +644,7 @@ method_configs["gaussian-splatting"] = TrainerConfig(
}, },
}, },
viewer=ViewerConfig(num_rays_per_chunk=1 << 15), viewer=ViewerConfig(num_rays_per_chunk=1 << 15),
vis="viewer_beta", vis="viewer",
) )
+17 -17
View File
@@ -36,8 +36,8 @@ from nerfstudio.utils.decorators import check_eval_enabled, check_main_thread, c
from nerfstudio.utils.misc import step_check from nerfstudio.utils.misc import step_check
from nerfstudio.utils.rich_utils import CONSOLE from nerfstudio.utils.rich_utils import CONSOLE
from nerfstudio.utils.writer import EventName, TimeWriter from nerfstudio.utils.writer import EventName, TimeWriter
from nerfstudio.viewer.server.viewer_state import ViewerState from nerfstudio.viewer_legacy.server.viewer_state import ViewerLegacyState
from nerfstudio.viewer_beta.viewer import Viewer as ViewerBetaState from nerfstudio.viewer.viewer import Viewer as ViewerState
from rich import box, style from rich import box, style
from rich.panel import Panel from rich.panel import Panel
from rich.table import Table from rich.table import Table
@@ -156,6 +156,19 @@ class Trainer:
# set up viewer if enabled # set up viewer if enabled
viewer_log_path = self.base_dir / self.config.viewer.relative_log_filename viewer_log_path = self.base_dir / self.config.viewer.relative_log_filename
self.viewer_state, banner_messages = None, None self.viewer_state, banner_messages = None, None
if self.config.is_viewer_legacy_enabled() and self.local_rank == 0:
datapath = self.config.data
if datapath is None:
datapath = self.base_dir
self.viewer_state = ViewerLegacyState(
self.config.viewer,
log_filename=viewer_log_path,
datapath=datapath,
pipeline=self.pipeline,
trainer=self,
train_lock=self.train_lock,
)
banner_messages = [f"Legacy viewer at: {self.viewer_state.viewer_url}"]
if self.config.is_viewer_enabled() and self.local_rank == 0: if self.config.is_viewer_enabled() and self.local_rank == 0:
datapath = self.config.data datapath = self.config.data
if datapath is None: if datapath is None:
@@ -167,22 +180,9 @@ class Trainer:
pipeline=self.pipeline, pipeline=self.pipeline,
trainer=self, trainer=self,
train_lock=self.train_lock, train_lock=self.train_lock,
)
banner_messages = [f"Viewer at: {self.viewer_state.viewer_url}"]
if self.config.is_viewer_beta_enabled() and self.local_rank == 0:
datapath = self.config.data
if datapath is None:
datapath = self.base_dir
self.viewer_state = ViewerBetaState(
self.config.viewer,
log_filename=viewer_log_path,
datapath=datapath,
pipeline=self.pipeline,
trainer=self,
train_lock=self.train_lock,
share=self.config.viewer.make_share_url, share=self.config.viewer.make_share_url,
) )
banner_messages = [f"Viewer Beta at: {self.viewer_state.viewer_url}"] banner_messages = [f"Viewer at: {self.viewer_state.viewer_url}"]
self._check_viewer_warnings() self._check_viewer_warnings()
self._load_checkpoint() self._load_checkpoint()
@@ -318,7 +318,7 @@ class Trainer:
def _check_viewer_warnings(self) -> None: def _check_viewer_warnings(self) -> None:
"""Helper to print out any warnings regarding the way the viewer/loggers are enabled""" """Helper to print out any warnings regarding the way the viewer/loggers are enabled"""
if ( if (
(self.config.is_viewer_enabled() or self.config.is_viewer_beta_enabled()) (self.config.is_viewer_legacy_enabled() or self.config.is_viewer_enabled())
and not self.config.is_tensorboard_enabled() and not self.config.is_tensorboard_enabled()
and not self.config.is_wandb_enabled() and not self.config.is_wandb_enabled()
and not self.config.is_comet_enabled() and not self.config.is_comet_enabled()
+15 -15
View File
@@ -30,8 +30,8 @@ from nerfstudio.engine.trainer import TrainerConfig
from nerfstudio.pipelines.base_pipeline import Pipeline from nerfstudio.pipelines.base_pipeline import Pipeline
from nerfstudio.utils import writer from nerfstudio.utils import writer
from nerfstudio.utils.eval_utils import eval_setup from nerfstudio.utils.eval_utils import eval_setup
from nerfstudio.viewer.server.viewer_state import ViewerState from nerfstudio.viewer_legacy.server.viewer_state import ViewerLegacyState
from nerfstudio.viewer_beta.viewer import Viewer as ViewerBetaState from nerfstudio.viewer.viewer import Viewer as ViewerState
@dataclass @dataclass
@@ -53,10 +53,10 @@ class RunViewer:
"""Path to config YAML file.""" """Path to config YAML file."""
viewer: ViewerConfigWithoutNumRays = field(default_factory=ViewerConfigWithoutNumRays) viewer: ViewerConfigWithoutNumRays = field(default_factory=ViewerConfigWithoutNumRays)
"""Viewer configuration""" """Viewer configuration"""
vis: Literal["viewer", "viewer_beta"] = "viewer" vis: Literal["viewer", "viewer_legacy"] = "viewer"
"""Type of viewer""" """Type of viewer"""
make_share_url: bool = False make_share_url: bool = True
"""Viewer beta feature: print a shareable URL. `vis` must be set to viewer_beta; this flag is otherwise ignored.""" """Print a shareable URL"""
def main(self) -> None: def main(self) -> None:
"""Main function.""" """Main function."""
@@ -92,23 +92,23 @@ def _start_viewer(config: TrainerConfig, pipeline: Pipeline, step: int):
viewer_log_path = base_dir / config.viewer.relative_log_filename viewer_log_path = base_dir / config.viewer.relative_log_filename
banner_messages = None banner_messages = None
viewer_state = None viewer_state = None
if config.vis == "viewer_legacy":
viewer_state = ViewerLegacyState(
config.viewer,
log_filename=viewer_log_path,
datapath=pipeline.datamanager.get_datapath(),
pipeline=pipeline,
)
banner_messages = [f"Legaccy viewer at: {viewer_state.viewer_url}"]
if config.vis == "viewer": if config.vis == "viewer":
viewer_state = ViewerState( viewer_state = ViewerState(
config.viewer, config.viewer,
log_filename=viewer_log_path, log_filename=viewer_log_path,
datapath=pipeline.datamanager.get_datapath(), datapath=pipeline.datamanager.get_datapath(),
pipeline=pipeline, pipeline=pipeline,
)
banner_messages = [f"Viewer at: {viewer_state.viewer_url}"]
if config.vis == "viewer_beta":
viewer_state = ViewerBetaState(
config.viewer,
log_filename=viewer_log_path,
datapath=pipeline.datamanager.get_datapath(),
pipeline=pipeline,
share=config.viewer.make_share_url, share=config.viewer.make_share_url,
) )
banner_messages = [f"Viewer Beta at: {viewer_state.viewer_url}"] banner_messages = [f"Viewer at: {viewer_state.viewer_url}"]
# We don't need logging, but writer.GLOBAL_BUFFER needs to be populated # We don't need logging, but writer.GLOBAL_BUFFER needs to be populated
config.logging.local_writer.enable = False config.logging.local_writer.enable = False
@@ -120,7 +120,7 @@ def _start_viewer(config: TrainerConfig, pipeline: Pipeline, step: int):
train_state="completed", train_state="completed",
eval_dataset=pipeline.datamanager.eval_dataset, eval_dataset=pipeline.datamanager.eval_dataset,
) )
if isinstance(viewer_state, ViewerState): if isinstance(viewer_state, ViewerLegacyState):
viewer_state.viser_server.set_training_state("completed") viewer_state.viser_server.set_training_state("completed")
viewer_state.update_scene(step=step) viewer_state.update_scene(step=step)
while True: while True:
@@ -20,7 +20,7 @@ from datetime import datetime
import tyro import tyro
from viser.infra import generate_typescript_interfaces from viser.infra import generate_typescript_interfaces
from nerfstudio.viewer.viser import NerfstudioMessage from nerfstudio.viewer_legacy.viser import NerfstudioMessage
def main() -> None: def main() -> None:
+2 -2
View File
@@ -50,11 +50,11 @@ def check_profiler_enabled(func: Callable) -> Callable:
def check_viewer_enabled(func: Callable) -> Callable: def check_viewer_enabled(func: Callable) -> Callable:
"""Decorator: check if the viewer or beta viewer is enabled and only run on main process""" """Decorator: check if the viewer or legacy viewer is enabled and only run on main process"""
def wrapper(self, *args, **kwargs): def wrapper(self, *args, **kwargs):
ret = None ret = None
if (self.config.is_viewer_enabled() or self.config.is_viewer_beta_enabled()) and comms.is_main_process(): if (self.config.is_viewer_enabled() or self.config.is_viewer_legacy_enabled()) and comms.is_main_process():
ret = func(self, *args, **kwargs) ret = func(self, *args, **kwargs)
return ret return ret
@@ -22,7 +22,7 @@ import viser
import viser.transforms as vtf import viser.transforms as vtf
from nerfstudio.data.scene_box import OrientedBox from nerfstudio.data.scene_box import OrientedBox
from nerfstudio.utils.colormaps import ColormapOptions, Colormaps from nerfstudio.utils.colormaps import ColormapOptions, Colormaps
from nerfstudio.viewer_beta.viewer_elements import ( # ViewerButtonGroup, from nerfstudio.viewer.viewer_elements import ( # ViewerButtonGroup,
ViewerButtonGroup, ViewerButtonGroup,
ViewerCheckbox, ViewerCheckbox,
ViewerDropdown, ViewerDropdown,
@@ -19,7 +19,7 @@ from pathlib import Path
import viser import viser
import viser.transforms as vtf import viser.transforms as vtf
from nerfstudio.data.scene_box import OrientedBox from nerfstudio.data.scene_box import OrientedBox
from nerfstudio.viewer_beta.control_panel import ControlPanel from nerfstudio.viewer.control_panel import ControlPanel
from typing_extensions import Literal from typing_extensions import Literal
@@ -68,9 +68,9 @@ def get_crop_string(obb: OrientedBox):
rpy = vtf.SO3.from_matrix(obb.R.numpy(force=True)).as_rpy_radians() rpy = vtf.SO3.from_matrix(obb.R.numpy(force=True)).as_rpy_radians()
pos = obb.T.squeeze().tolist() pos = obb.T.squeeze().tolist()
scale = obb.S.squeeze().tolist() scale = obb.S.squeeze().tolist()
rpystring = " ".join([str(x) for x in rpy]) rpystring = " ".join([f"{x:.10f}" for x in rpy])
posstring = " ".join([str(x) for x in pos]) posstring = " ".join([f"{x:.10f}" for x in pos])
scalestring = " ".join([str(x) for x in scale]) scalestring = " ".join([f"{x:.10f}" for x in scale])
return f"--obb_center {posstring} --obb_rotation {rpystring} --obb_scale {scalestring}" return f"--obb_center {posstring} --obb_rotation {rpystring} --obb_scale {scalestring}"
@@ -20,16 +20,15 @@ import datetime
import json import json
import threading import threading
import time import time
from typing import Dict, List, Optional, Tuple, Literal
from pathlib import Path from pathlib import Path
from typing import Dict, List, Literal, Optional, Tuple from nerfstudio.viewer.control_panel import ControlPanel
import numpy as np
import scipy.interpolate
import splines import splines
import splines.quaternion import splines.quaternion
import viser import viser
import viser.transforms as tf import viser.transforms as tf
from nerfstudio.viewer_beta.control_panel import ControlPanel import numpy as np
import scipy
@dataclasses.dataclass @dataclasses.dataclass
@@ -465,7 +464,7 @@ def populate_render_tab(
datapath: Path, datapath: Path,
control_panel: Optional[ControlPanel] = None, control_panel: Optional[ControlPanel] = None,
) -> RenderTabState: ) -> RenderTabState:
from nerfstudio.viewer_beta.viewer import VISER_NERFSTUDIO_SCALE_RATIO from nerfstudio.viewer.viewer import VISER_NERFSTUDIO_SCALE_RATIO
render_tab_state = RenderTabState( render_tab_state = RenderTabState(
preview_render=False, preview_render=False,
@@ -668,7 +667,7 @@ def populate_render_tab(
min=0.001, min=0.001,
max=30.0, max=30.0,
step=0.001, step=0.001,
initial_value=0.5, initial_value=2.0,
hint="Time in seconds between each keyframe, which can also be overridden on a per-transition basis.", hint="Time in seconds between each keyframe, which can also be overridden on a per-transition basis.",
) )
framerate_number = server.add_gui_number("FPS", min=0.1, max=240.0, step=1e-2, initial_value=30.0) framerate_number = server.add_gui_number("FPS", min=0.1, max=240.0, step=1e-2, initial_value=30.0)
@@ -27,12 +27,12 @@ from nerfstudio.model_components.renderers import background_color_override_cont
from nerfstudio.models.gaussian_splatting import GaussianSplattingModel from nerfstudio.models.gaussian_splatting import GaussianSplattingModel
from nerfstudio.utils import colormaps, writer from nerfstudio.utils import colormaps, writer
from nerfstudio.utils.writer import GLOBAL_BUFFER, EventName, TimeWriter from nerfstudio.utils.writer import GLOBAL_BUFFER, EventName, TimeWriter
from nerfstudio.viewer.server import viewer_utils from nerfstudio.viewer_legacy.server import viewer_utils
from nerfstudio.viewer_beta.utils import CameraState, get_camera from nerfstudio.viewer.utils import CameraState, get_camera
from viser import ClientHandle from viser import ClientHandle
if TYPE_CHECKING: if TYPE_CHECKING:
from nerfstudio.viewer_beta.viewer import Viewer from nerfstudio.viewer.viewer import Viewer
RenderStates = Literal["low_move", "low_static", "high"] RenderStates = Literal["low_move", "low_static", "high"]
RenderActions = Literal["rerender", "move", "static", "step"] RenderActions = Literal["rerender", "move", "static", "step"]
File renamed without changes.
@@ -34,13 +34,13 @@ from nerfstudio.models.base_model import Model
from nerfstudio.pipelines.base_pipeline import Pipeline from nerfstudio.pipelines.base_pipeline import Pipeline
from nerfstudio.utils.decorators import check_main_thread, decorate_all from nerfstudio.utils.decorators import check_main_thread, decorate_all
from nerfstudio.utils.writer import GLOBAL_BUFFER, EventName from nerfstudio.utils.writer import GLOBAL_BUFFER, EventName
from nerfstudio.viewer.server import viewer_utils from nerfstudio.viewer_legacy.server import viewer_utils
from nerfstudio.viewer_beta.control_panel import ControlPanel from nerfstudio.viewer.control_panel import ControlPanel
from nerfstudio.viewer_beta.export_panel import populate_export_tab from nerfstudio.viewer.export_panel import populate_export_tab
from nerfstudio.viewer_beta.render_panel import populate_render_tab from nerfstudio.viewer.render_panel import populate_render_tab
from nerfstudio.viewer_beta.render_state_machine import RenderAction, RenderStateMachine from nerfstudio.viewer.render_state_machine import RenderAction, RenderStateMachine
from nerfstudio.viewer_beta.utils import CameraState, parse_object from nerfstudio.viewer.utils import CameraState, parse_object
from nerfstudio.viewer_beta.viewer_elements import ViewerControl, ViewerElement from nerfstudio.viewer.viewer_elements import ViewerControl, ViewerElement
from typing_extensions import assert_never from typing_extensions import assert_never
if TYPE_CHECKING: if TYPE_CHECKING:
@@ -35,11 +35,11 @@ from viser import (
ViserServer, ViserServer,
) )
from nerfstudio.viewer.utils import CameraState, get_camera
from nerfstudio.cameras.cameras import Cameras, CameraType from nerfstudio.cameras.cameras import Cameras, CameraType
from nerfstudio.viewer_beta.utils import CameraState, get_camera
if TYPE_CHECKING: if TYPE_CHECKING:
from nerfstudio.viewer_beta.viewer import Viewer from nerfstudio.viewer.viewer import Viewer
TValue = TypeVar("TValue") TValue = TypeVar("TValue")
TString = TypeVar("TString", default=str, bound=str) TString = TypeVar("TString", default=str, bound=str)
@@ -133,7 +133,7 @@ class ViewerControl:
if not client_id: if not client_id:
client_id = list(clients.keys())[0] client_id = list(clients.keys())[0]
from nerfstudio.viewer_beta.viewer import VISER_NERFSTUDIO_SCALE_RATIO from nerfstudio.viewer.viewer import VISER_NERFSTUDIO_SCALE_RATIO
client = clients[client_id] client = clients[client_id]
R = vtf.SO3(wxyz=client.camera.wxyz) R = vtf.SO3(wxyz=client.camera.wxyz)
@@ -154,7 +154,7 @@ class ViewerControl:
cb: The callback to call when a click is detected. cb: The callback to call when a click is detected.
The callback should take a ViewerClick object as an argument The callback should take a ViewerClick object as an argument
""" """
from nerfstudio.viewer_beta.viewer import VISER_NERFSTUDIO_SCALE_RATIO from nerfstudio.viewer.viewer import VISER_NERFSTUDIO_SCALE_RATIO
def wrapped_cb(scene_pointer_msg: ScenePointerEvent): def wrapped_cb(scene_pointer_msg: ScenePointerEvent):
# only call the callback if the event is a click # only call the callback if the event is a click
File renamed without changes.
@@ -2,4 +2,4 @@ BROWSER=none
FAST_REFRESH=false FAST_REFRESH=false
HOST=0.0.0.0 HOST=0.0.0.0
PORT=4000 PORT=4000
ESLINT_NO_DEV_ERRORS=true ESLINT_NO_DEV_ERRORS=true
@@ -11,4 +11,4 @@ npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
/.changelog /.changelog
.npm/ .npm/
@@ -93,4 +93,4 @@
"resolve-url-loader": "^5.0.0", "resolve-url-loader": "^5.0.0",
"yaml": "^2.2.2" "yaml": "^2.2.2"
} }
} }
File renamed without changes.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

File renamed without changes.
@@ -162,4 +162,4 @@ export function drawCameras(cameras): Record<number, THREE.Object3D> {
cameraObjects[key] = drawCamera(camera); cameraObjects[key] = drawCamera(camera);
} }
return cameraObjects; return cameraObjects;
} }
@@ -333,7 +333,7 @@ export default function ViewerWindow(props) {
mouseVector.y > 1 || mouseVector.y > 1 ||
mouseVector.y < -1 mouseVector.y < -1
); );
if (!mouse_in_scene) { return; } if (!mouse_in_scene) { return; }
const raycaster = new THREE.Raycaster(); const raycaster = new THREE.Raycaster();
raycaster.setFromCamera(mouseVector, sceneTree.metadata.camera); raycaster.setFromCamera(mouseVector, sceneTree.metadata.camera);
@@ -341,13 +341,13 @@ export default function ViewerWindow(props) {
throttledClickSender({ throttledClickSender({
type: 'ClickMessage', type: 'ClickMessage',
origin: [ origin: [
raycaster.ray.origin.x, raycaster.ray.origin.x,
raycaster.ray.origin.y, raycaster.ray.origin.y,
raycaster.ray.origin.z raycaster.ray.origin.z
], ],
direction: [ direction: [
raycaster.ray.direction.x, raycaster.ray.direction.x,
raycaster.ray.direction.y, raycaster.ray.direction.y,
raycaster.ray.direction.z raycaster.ray.direction.z
], ],
}); });
@@ -116,7 +116,7 @@ interface OutputOptionsMessage {
options: any; options: any;
} }
export type Message = export type Message =
| BackgroundImageMessage | BackgroundImageMessage
| GuiAddMessage | GuiAddMessage
| GuiRemoveMessage | GuiRemoveMessage
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -19,7 +19,7 @@ from typing import Callable, DefaultDict, List, Tuple, get_args
import torch import torch
from nerfstudio.utils.colormaps import ColormapOptions, Colormaps from nerfstudio.utils.colormaps import ColormapOptions, Colormaps
from nerfstudio.viewer.server.viewer_elements import ( from nerfstudio.viewer_legacy.server.viewer_elements import (
ViewerButtonGroup, ViewerButtonGroup,
ViewerCheckbox, ViewerCheckbox,
ViewerDropdown, ViewerDropdown,
@@ -29,7 +29,7 @@ from nerfstudio.viewer.server.viewer_elements import (
ViewerSlider, ViewerSlider,
ViewerVec3, ViewerVec3,
) )
from nerfstudio.viewer.viser import ViserServer from nerfstudio.viewer_legacy.viser import ViserServer
class ControlPanel: class ControlPanel:
File renamed without changes.
@@ -27,11 +27,11 @@ from nerfstudio.model_components.renderers import background_color_override_cont
from nerfstudio.models.gaussian_splatting import GaussianSplattingModel from nerfstudio.models.gaussian_splatting import GaussianSplattingModel
from nerfstudio.utils import colormaps, writer from nerfstudio.utils import colormaps, writer
from nerfstudio.utils.writer import GLOBAL_BUFFER, EventName, TimeWriter from nerfstudio.utils.writer import GLOBAL_BUFFER, EventName, TimeWriter
from nerfstudio.viewer.server import viewer_utils from nerfstudio.viewer_legacy.server import viewer_utils
from nerfstudio.viewer.viser.messages import CameraMessage from nerfstudio.viewer_legacy.viser.messages import CameraMessage
if TYPE_CHECKING: if TYPE_CHECKING:
from nerfstudio.viewer.server.viewer_state import ViewerState from nerfstudio.viewer_legacy.server.viewer_state import ViewerLegacyState
RenderStates = Literal["low_move", "low_static", "high"] RenderStates = Literal["low_move", "low_static", "high"]
RenderActions = Literal["rerender", "move", "static", "step"] RenderActions = Literal["rerender", "move", "static", "step"]
@@ -55,7 +55,7 @@ class RenderStateMachine(threading.Thread):
viewer: the viewer state viewer: the viewer state
""" """
def __init__(self, viewer: ViewerState): def __init__(self, viewer: ViewerLegacyState):
threading.Thread.__init__(self) threading.Thread.__init__(self)
self.transitions: Dict[RenderStates, Dict[RenderActions, RenderStates]] = { self.transitions: Dict[RenderStates, Dict[RenderActions, RenderStates]] = {
s: {} for s in get_args(RenderStates) s: {} for s in get_args(RenderStates)
@@ -13,7 +13,7 @@
# limitations under the License. # limitations under the License.
from nerfstudio.viewer.server.state.node import Node from nerfstudio.viewer_legacy.server.state.node import Node
class StateNode(Node): class StateNode(Node):
@@ -21,7 +21,7 @@ import numpy as np
import torch import torch
from typing_extensions import assert_never from typing_extensions import assert_never
from nerfstudio.viewer.viser.messages import CameraMessage from nerfstudio.viewer_legacy.viser.messages import CameraMessage
def get_chunks( def get_chunks(
@@ -25,12 +25,12 @@ from typing import TYPE_CHECKING, Any, Callable, Generic, List, Optional, Tuple
from typing_extensions import TypeVar from typing_extensions import TypeVar
from nerfstudio.cameras.cameras import Cameras from nerfstudio.cameras.cameras import Cameras
from nerfstudio.viewer.viser import GuiHandle, GuiSelectHandle, ViserServer from nerfstudio.viewer_legacy.viser import GuiHandle, GuiSelectHandle, ViserServer
from nerfstudio.viewer.viser.messages import ClickMessage from nerfstudio.viewer_legacy.viser.messages import ClickMessage
if TYPE_CHECKING: if TYPE_CHECKING:
from nerfstudio.viewer.server.control_panel import ControlPanel from nerfstudio.viewer_legacy.server.control_panel import ControlPanel
from nerfstudio.viewer.server.viewer_state import ViewerState from nerfstudio.viewer_legacy.server.viewer_state import ViewerLegacyState
TValue = TypeVar("TValue") TValue = TypeVar("TValue")
@@ -61,8 +61,14 @@ class ViewerControl:
def __init__(self): def __init__(self):
# this should be a user-facing constructor, since it will be used inside the model/pipeline class # this should be a user-facing constructor, since it will be used inside the model/pipeline class
self.click_cbs = [] self.click_cbs = []
from nerfstudio.utils.rich_utils import CONSOLE
def _setup(self, viewer_state: ViewerState): CONSOLE.print(
"WARNING: viewer_legacy.server.viewer_elements is deprecated and will be removed in the future. Use the new nerfstudio.viewer instead",
style="bold yellow",
)
def _setup(self, viewer_state: ViewerLegacyState):
""" """
Internal use only, setup the viewer control with the viewer state object Internal use only, setup the viewer control with the viewer state object
@@ -162,6 +168,12 @@ class ViewerElement(Generic[TValue]):
self.gui_handle: Optional[GuiHandle[TValue]] = None self.gui_handle: Optional[GuiHandle[TValue]] = None
self.disabled = disabled self.disabled = disabled
self.cb_hook = cb_hook self.cb_hook = cb_hook
from nerfstudio.utils.rich_utils import CONSOLE
CONSOLE.print(
"WARNING: viewer_legacy.server.viewer_elements is deprecated and will be removed in the future. Use the new nerfstudio.viewer instead",
style="bold yellow",
)
@abstractmethod @abstractmethod
def _create_gui_handle(self, viser_server: ViserServer) -> None: def _create_gui_handle(self, viser_server: ViserServer) -> None:
@@ -35,14 +35,14 @@ from nerfstudio.utils.decorators import check_main_thread, decorate_all
from nerfstudio.utils.io import load_from_json, write_to_json from nerfstudio.utils.io import load_from_json, write_to_json
from nerfstudio.utils.rich_utils import CONSOLE from nerfstudio.utils.rich_utils import CONSOLE
from nerfstudio.utils.writer import GLOBAL_BUFFER, EventName from nerfstudio.utils.writer import GLOBAL_BUFFER, EventName
from nerfstudio.viewer.server import viewer_utils from nerfstudio.viewer_legacy.server import viewer_utils
from nerfstudio.viewer.server.control_panel import ControlPanel from nerfstudio.viewer_legacy.server.control_panel import ControlPanel
from nerfstudio.viewer.server.gui_utils import parse_object from nerfstudio.viewer_legacy.server.gui_utils import parse_object
from nerfstudio.viewer.server.render_state_machine import RenderAction, RenderStateMachine from nerfstudio.viewer_legacy.server.render_state_machine import RenderAction, RenderStateMachine
from nerfstudio.viewer.server.utils import get_intrinsics_matrix_and_camera_to_world_h from nerfstudio.viewer_legacy.server.utils import get_intrinsics_matrix_and_camera_to_world_h
from nerfstudio.viewer.server.viewer_elements import ViewerControl, ViewerElement from nerfstudio.viewer_legacy.server.viewer_elements import ViewerControl, ViewerElement
from nerfstudio.viewer.viser import ViserServer from nerfstudio.viewer_legacy.viser import ViserServer
from nerfstudio.viewer.viser.messages import ( from nerfstudio.viewer_legacy.viser.messages import (
CameraMessage, CameraMessage,
CameraPathOptionsRequest, CameraPathOptionsRequest,
CameraPathPayloadMessage, CameraPathPayloadMessage,
@@ -59,7 +59,7 @@ if TYPE_CHECKING:
@decorate_all([check_main_thread]) @decorate_all([check_main_thread])
class ViewerState: class ViewerLegacyState:
"""Class to hold state for viewer variables """Class to hold state for viewer variables
Args: Args:
File renamed without changes.
File renamed without changes.