Skip to content

Commit

Permalink
Gracefuly handle old ViewerElements from legacy viewer (#2797)
Browse files Browse the repository at this point in the history
* fix jittering in markdown in viewer beta

* Revert "fix jittering in markdown in viewer beta"

This reverts commit 70ade42.

* 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 ayaanzhaque/instruct-nerf2nerf#88

* Fix typo

* suppress ruff error

---------

Co-authored-by: Brent Yi <[email protected]>
  • Loading branch information
kerrj and brentyi authored Jan 20, 2024
1 parent 248e99e commit 616846b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/nerfology/methods/splat.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
14 changes: 14 additions & 0 deletions nerfstudio/viewer/server/__init__.py
Original file line number Diff line number Diff line change
@@ -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.

19 changes: 19 additions & 0 deletions nerfstudio/viewer/server/viewer_elements.py
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions nerfstudio/viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 616846b

Please sign in to comment.