From 616846b10ed6449e20d3b256b4acba323cf54f77 Mon Sep 17 00:00:00 2001 From: Justin Kerr Date: Fri, 19 Jan 2024 16:37:40 -0800 Subject: [PATCH] Gracefuly handle old ViewerElements from legacy viewer (#2797) * fix jittering in markdown in viewer beta * Revert "fix jittering in markdown in viewer beta" This reverts commit 70ade42e46f3dcf0e89e4efc445650f6d6525673. * print correctly formatted url in banner for viewer beta * warn when legacy viewerelements are used in new viewer * Add shim for viewer_elements namespace, fixes https://github.com/ayaanzhaque/instruct-nerf2nerf/pull/88 * Fix typo * suppress ruff error --------- Co-authored-by: Brent Yi --- docs/nerfology/methods/splat.md | 2 +- nerfstudio/viewer/server/__init__.py | 14 ++++++++++++++ nerfstudio/viewer/server/viewer_elements.py | 19 +++++++++++++++++++ nerfstudio/viewer/viewer.py | 9 +++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 nerfstudio/viewer/server/__init__.py create mode 100644 nerfstudio/viewer/server/viewer_elements.py diff --git a/docs/nerfology/methods/splat.md b/docs/nerfology/methods/splat.md index 8cfbefa44d..f36973bd0f 100644 --- a/docs/nerfology/methods/splat.md +++ b/docs/nerfology/methods/splat.md @@ -23,7 +23,7 @@ GSplat Nerfstudio uses [gsplat](https://github.com/nerfstudio-project/gsplat) as its gaussian rasterization backend, an in-house re-implementation which is designed to be more developer friendly. This can be installed with `pip install gsplat`. The associated CUDA code will be compiled the first time gsplat is executed. Some users with PyTorch 2.0 have experienced issues with this, which can be resolved by either installing gsplat from source, or upgrading torch to 2.1. ### Data -Gaussian spltting works much better if you initialize it from pre-existing geometry, such as SfM points from COLMAP. COLMAP datasets or datasets from `ns-process-data` will automatically save these points and initialize gaussians on them. Other datasets currently do not support initialization, and will initialize gaussians randomly. Initializing from other data inputs (i.e. depth from phone app scanners) may be supported in the future. +Gaussian splatting works much better if you initialize it from pre-existing geometry, such as SfM points from COLMAP. COLMAP datasets or datasets from `ns-process-data` will automatically save these points and initialize gaussians on them. Other datasets currently do not support initialization, and will initialize gaussians randomly. Initializing from other data inputs (i.e. depth from phone app scanners) may be supported in the future. Because the method trains on *full images* instead of bundles of rays, there is a new datamanager in `full_images_datamanager.py` which undistorts input images, caches them, and provides single images at each train step. diff --git a/nerfstudio/viewer/server/__init__.py b/nerfstudio/viewer/server/__init__.py new file mode 100644 index 0000000000..40c3732998 --- /dev/null +++ b/nerfstudio/viewer/server/__init__.py @@ -0,0 +1,14 @@ +# Copyright 2022 the Regents of the University of California, Nerfstudio Team and contributors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/nerfstudio/viewer/server/viewer_elements.py b/nerfstudio/viewer/server/viewer_elements.py new file mode 100644 index 0000000000..2689e432b3 --- /dev/null +++ b/nerfstudio/viewer/server/viewer_elements.py @@ -0,0 +1,19 @@ +# Copyright 2022 the Regents of the University of California, Nerfstudio Team and contributors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Shim for viewer_elements.py, which has been moved. + +Resolves issues like: https://github.com/ayaanzhaque/instruct-nerf2nerf/pull/88 +""" +from ..viewer_elements import * # noqa diff --git a/nerfstudio/viewer/viewer.py b/nerfstudio/viewer/viewer.py index 4480bf214e..208b8da681 100644 --- a/nerfstudio/viewer/viewer.py +++ b/nerfstudio/viewer/viewer.py @@ -235,6 +235,15 @@ def nested_folder_install(folder_labels: List[str], prev_labels: List[str], elem nested_folder_install(folder_labels[1:], prev_labels + [folder_labels[0]], element) with control_tab: + from nerfstudio.viewer_legacy.server.viewer_elements import ViewerElement as LegacyViewerElement + + if len(parse_object(pipeline, LegacyViewerElement, "Custom Elements")) > 0: + from nerfstudio.utils.rich_utils import CONSOLE + + CONSOLE.print( + "Legacy ViewerElements detected in model, please import nerfstudio.viewer.viewer_elements instead", + style="bold yellow", + ) self.viewer_elements = [] self.viewer_elements.extend(parse_object(pipeline, ViewerElement, "Custom Elements")) for param_path, element in self.viewer_elements: