Skip to content

Commit 6958fe0

Browse files
committed
Squashed commit of the following:
commit d9b022b Author: J.Y <[email protected]> Date: Fri Apr 19 14:03:55 2024 -0400 Allow alpha transparency training for blender datasets input (nerfstudio-project#3088) Allow alpha transparency training for rgba input Co-authored-by: Justin Kerr <[email protected]> commit eddf2d2 Author: Congrong Xu <[email protected]> Date: Thu Apr 18 17:37:50 2024 -0700 Changes for trainer.py to support the Gradio webui (nerfstudio-project#3046) * changes for trainer to support webui * Update trainer to support webui * format * add a seperated shutdown() function to stop training * typo fix * get rid of _stop_viewer_server() * Update trainer.py * organize import --------- Co-authored-by: Brent Yi <[email protected]> commit 45d8bb7 Author: Justin Kerr <[email protected]> Date: Wed Apr 17 23:54:43 2024 -0700 updates to apply_pca_colormap (nerfstudio-project#3086) * improvements to pca_colormap: allow input pca matrix, optional ignore_zeros arg * typo commit babf577 Author: Patrick Morgan <[email protected]> Date: Fri Apr 12 14:23:47 2024 -0700 Fix call to detect ODM reconstruction file (nerfstudio-project#3018) commit a64026f Author: Justin Kerr <[email protected]> Date: Fri Apr 12 12:32:22 2024 -0700 shift principle points by .5 in undistortion (nerfstudio-project#3071) * shift principle points by .5 * fix ordering * add fisheye offset commit c302cc5 Author: Gunjan Chhablani <[email protected]> Date: Thu Apr 11 16:41:14 2024 -0400 Add pointcloud loading for blender parser (nerfstudio-project#2902) * Add pointcloud loading for blender parser * Fix argument * Fix docstring * Fix metadata in dataparsers * Add changes from review * Avoid changing default behavior * Apply `scale_factor` to loaded points --------- Co-authored-by: Brent Yi <[email protected]> commit 03bdeff Author: hyperzy <[email protected]> Date: Thu Apr 11 14:56:37 2024 -0400 Fixed Unexpectedly huge RAM consumption of parallel datamanager (nerfstudio-project#3060) * Reduced the memory usage by caching image after the datamanager process starts commit 4714ae7 Author: J.Y <[email protected]> Date: Thu Apr 11 14:37:02 2024 -0400 write eval combined images for diagnostics (nerfstudio-project#3070) commit eba72db Author: Otto Seiskari <[email protected]> Date: Thu Apr 11 21:23:17 2024 +0300 Camera pose optimization for Splatfacto (nerfstudio-project#2891) * Add pose optimization to Splatfacto * Disable Splatfacto pose optimization by default * Improve apply_to_camera for Gaussian Splatting pose optimization Do not chain modifications to camera_to_worlds to improve numerical stability and enable L2 rot/trans penalties. * Add separate mean and max rot/trans metrics to camera-opt * Tweak pose optimization hyperparameters Parameters used in the Gaussian Splatting on the Move paper v1 * Unit test fix for new cameara_optimizer training metrics * Adjust splatfacto-big camera pose optimization parameters Same parameters as in normal Splatfacto --------- Co-authored-by: jh-surh <[email protected]> commit 2d9bbe5 Author: dberga <[email protected]> Date: Thu Apr 11 04:04:33 2024 +0200 fix exporter.py for FullImageDataManager and RandomCamerasDataManager (nerfstudio-project#3065) * fix exporter.py for FullImageDataManager and RandomCamerasDataManager * sort imports * ruff --------- Co-authored-by: Brent Yi <[email protected]> commit c381fc8 Author: Justin Kerr <[email protected]> Date: Wed Apr 10 18:59:20 2024 -0700 Fix custom elements nested under @Property (nerfstudio-project#3066) * patch custom elements bug * Skip `cached_property` * fomrat * comment, type hint --------- Co-authored-by: Brent Yi <[email protected]> commit d1fc2ee Author: Saurav Maheshkar <[email protected]> Date: Mon Apr 8 23:46:00 2024 +0100 feat(ci): migrate to `uv` in CI (nerfstudio-project#3038) * feat(ci): migrate to `uv` in CI * feat(ci): drop upgrade strategy * feat(ci): use `uv` in docs workflow * fix(ci/doc): update sphinx build cmd * fix(ci/doc): specify python path * (experimental) simplify * remove venv * Revert line wrap change for doc.yml --------- Co-authored-by: Brent Yi <[email protected]> commit 2b91715 Author: Sahil Jain <[email protected]> Date: Mon Apr 8 13:04:20 2024 -0400 Fix config loading for Eyeful Tower dataset (nerfstudio-project#3054) Add test_filenames to transforms.json generated by eyeful_tower.py commit 26804f8 Author: Ling Jing <[email protected]> Date: Tue Apr 9 00:07:21 2024 +0800 Make colmapDataParser compatible with 360_v2 dataset format (nerfstudio-project#2860) * added an option to colmapdataparser to round up the image size when downscaling * add round mode and update ffmpeg command * [fix] wrong variable order * update format --------- Co-authored-by: Jing <[email protected]> commit 911091c Author: Jan-Niklas Dihlmann <[email protected]> Date: Mon Apr 8 16:17:56 2024 +0200 Added SIGNeRF to Nerfstudio methods (nerfstudio-project#3053) * feat: signerf as nerfstudio method * fix: formating issues and indexing
1 parent 48050dc commit 6958fe0

23 files changed

+361
-70
lines changed

.github/workflows/core_code_checks.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@ jobs:
2525
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
2626
- name: Install dependencies
2727
run: |
28-
pip install --upgrade --upgrade-strategy eager -e .[dev]
28+
pip install uv
29+
uv pip install --system --upgrade -e .[dev]
2930
- name: Run license checks
3031
run: |
3132
./nerfstudio/scripts/licensing/license_headers.sh --check
3233
- name: Check notebook cell metadata
3334
run: |
3435
python ./nerfstudio/scripts/docs/add_nb_tags.py --check
3536
- name: Run Ruff Linter
36-
run: ruff check docs/ nerfstudio/ tests/ --output-format=github
37+
run: |
38+
ruff check docs/ nerfstudio/ tests/ --output-format=github
3739
- name: Run Ruff Formatter
38-
run: ruff format docs/ nerfstudio/ tests/ --diff
40+
run: |
41+
ruff format docs/ nerfstudio/ tests/ --diff
3942
- name: Run Pyright
4043
run: |
4144
pyright

.github/workflows/doc.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ jobs:
1818
python-version: '3.9'
1919
- name: Install dependencies
2020
run: |
21-
pip install .[docs]
21+
pip install uv
22+
uv pip install --system .[docs]
2223
- name: Sphinx build
2324
# fail on warnings
2425
run: |

docs/index.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,13 @@ This documentation is organized into 3 parts:
148148
### Third-party Methods
149149

150150
- [Instruct-NeRF2NeRF](nerfology/methods/in2n.md): Editing 3D Scenes with Instructions
151+
- [Instruct-GS2GS](nerfology/methods/igs2gs.md): Editing 3DGS Scenes with Instructions
152+
- [SIGNeRF](nerfology/methods/signerf.md): Controlled Generative Editing of NeRF Scenes
151153
- [K-Planes](nerfology/methods/kplanes.md): Unified 3D and 4D Radiance Fields
152154
- [LERF](nerfology/methods/lerf.md): Language Embedded Radiance Fields
153155
- [Nerfbusters](nerfology/methods/nerfbusters.md): Removing Ghostly Artifacts from Casually Captured NeRFs
154156
- [NeRFPlayer](nerfology/methods/nerfplayer.md): 4D Radiance Fields by Streaming Feature Channels
155157
- [Tetra-NeRF](nerfology/methods/tetranerf.md): Representing Neural Radiance Fields Using Tetrahedra
156-
- [Instruct-GS2GS](nerfology/methods/igs2gs.md): Editing 3DGS Scenes with Instructions
157158
- [PyNeRF](nerfology/methods/pynerf.md): Pyramidal Neural Radiance Fields
158159
- [SeaThru-NeRF](nerfology/methods/seathru_nerf.md): Neural Radiance Field for subsea scenes
159160
- [Zip-NeRF](nerfology/methods/zipnerf.md): Anti-Aliased Grid-Based Neural Radiance Fields
@@ -162,13 +163,14 @@ This documentation is organized into 3 parts:
162163

163164
## Quicklinks
164165

165-
| | |
166-
| ---------------------------------------------------------- | ---------------------- |
167-
| [Github](https://github.com/nerfstudio-project/nerfstudio) | Official Github Repo |
168-
| [Discord](https://discord.gg/RyVk6w5WWP) | Join Discord Community |
166+
| | |
167+
| ---------------------------------------------------------- | --------------------------- |
168+
| [Github](https://github.com/nerfstudio-project/nerfstudio) | Official Github Repo |
169+
| [Discord](https://discord.gg/RyVk6w5WWP) | Join Discord Community |
169170
| [Feedback Form](https://forms.gle/sqN5phJN7LfQVwnP9) | Provide Nerfstudio Feedback |
170171

171172
## Sponsors
173+
172174
Sponsors of this work includes [Luma AI](https://lumalabs.ai/) and the [BAIR commons](https://bcommons.berkeley.edu/home).
173175

174176
| | |

docs/nerfology/methods/index.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ The following methods are supported in nerfstudio:
2929
Instant-NGP<instant_ngp.md>
3030
Splatfacto<splat.md>
3131
Instruct-NeRF2NeRF<in2n.md>
32+
Instruct-GS2GS<igs2gs.md>
33+
SIGNeRF<signerf.md>
3234
K-Planes<kplanes.md>
3335
LERF<lerf.md>
3436
Mip-NeRF<mipnerf.md>
@@ -39,7 +41,6 @@ The following methods are supported in nerfstudio:
3941
Tetra-NeRF<tetranerf.md>
4042
TensoRF<tensorf.md>
4143
Generfacto<generfacto.md>
42-
Instruct-GS2GS<igs2gs.md>
4344
PyNeRF<pynerf.md>
4445
SeaThru-NeRF<seathru_nerf.md>
4546
Zip-NeRF<zipnerf.md>

docs/nerfology/methods/signerf.md

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# SIGNeRF
2+
3+
<h3> Scene Integrated Generation for Neural Radiance Fields</h3>
4+
5+
```{button-link} https://signerf.jdihlmann.com/
6+
:color: primary
7+
:outline:
8+
Website & Code
9+
```
10+
11+
<video id="teaser" muted autoplay playsinline loop controls width="100%">
12+
<source id="mp4" src="https://signerf.jdihlmann.com/videos/SIGNeRF_small.mp4" type="video/mp4">
13+
</video>
14+
15+
**Generatively edits NeRF scenes in a controlled and fast manner.**
16+
17+
SIGNeRF allows for generative 3D scene editing. We present a novel approach to combine [NeRFs](https://www.matthewtancik.com/nerf) as scene representation with the image diffusion model [StableDiffusion](https://github.com/Stability-AI/stablediffusion) to allow fast and controlled 3D generation.
18+
19+
## Installation
20+
21+
Install nerfstudio dependencies. Then run:
22+
23+
```bash
24+
pip install git+https://github.com/cgtuebingen/SIGNeRF
25+
```
26+
27+
SIGNeRF requires to use [Stable Diffusion Web UI](https://github.com/AUTOMATIC1111/stable-diffusion-webui). For detailed installation information follow our [installation guide](https://github.com/cgtuebingen/SIGNeRF?tab=readme-ov-file#installation).
28+
29+
## Running SIGNeRF
30+
31+
Details for running SIGNeRF can be found [here](https://github.com/cgtuebingen/SIGNeRF). Once installed, run:
32+
33+
```bash
34+
ns-train signerf --help
35+
```
36+
37+
Two variants of SIGNeRF are provided:
38+
39+
| Method | Description | Time | Quality |
40+
| ------------------ | -------------------------- | ----- | ------- |
41+
| `signerf` | Full model, used in paper | 40min | Best |
42+
| `signerf_nerfacto` | Faster model with Nerfacto | 20min | Good |
43+
44+
For more information on hardware requirements and training times, please refer to the [training section](https://github.com/cgtuebingen/SIGNeRF?tab=readme-ov-file#training-1).
45+
46+
## Interface
47+
48+
<img src="https://github.com/cgtuebingen/SIGNeRF/raw/main/images/interface.png" width="100%" alt="SIGNeRF Interface" />
49+
50+
SIGNeRF fully integrates into the Nerfstudio [viser](https://viser.studio) interface. It allows for easy editing of NeRF scenes with a few simple clicks. The user can select the editing method, the region to edit, and the object to insert. The reference sheet can be previewed and the NeRF is fine-tuned on the edited images. If you are interested in how we fully edit the Nerfstudio interface please find our code [here](https://github.com/cgtuebingen/SIGNeRF).
51+
52+
## Method
53+
54+
### Overview
55+
56+
SIGNeRF is a novel approach for fast and controllable NeRF scene editing and scene-integrated object generation. We introduce a new generative update strategy that ensures 3D consistency across the edited images, without requiring iterative optimization. We find that depth-conditioned diffusion models inherently possess the capability to generate 3D consistent views by requesting a grid of images instead of single views. Based on these insights, we introduce a multi-view reference sheet of modified images. Our method updates an image collection consistently based on the reference sheet and refines the original NeRF with the newly generated image set in one go. By exploiting the depth conditioning mechanism of the image diffusion model, we gain fine control over the spatial location of the edit and enforce shape guidance by a selected region or an external mesh.
57+
58+
For an in-depth visual explanation and our results please watch our [videos](https://www.youtube.com/playlist?list=PL5y23CB9WmildtW3QyMEi3arXg06zB4ex) or read our [paper](https://arxiv.org/abs/2401.01647).
59+
60+
## Pipeline
61+
62+
<video id="pipeline" muted autoplay playsinline loop controls width="100%">
63+
<source id="mp4" src="https://signerf.jdihlmann.com/videos/pipeline_compressed.mp4" type="video/mp4">
64+
</video>
65+
66+
We leverage the strengths of [ControlNet](https://github.com/lllyasviel/ControlNet), a depth condition image diffusion model, to edit an existing NeRF scene. We do so with a few simple steps in a single forward pass:
67+
68+
0. We start with an original NeRF scene and select an editing method / region
69+
1. For object generation, we place a mesh object into the scene
70+
2. And control the precise location and shape of the edit
71+
3. We position reference cameras in the scene
72+
4. Render the corresponding color, depth, and mask images, and arrange them into image grids
73+
5. These grids are used to generate the reference sheet with conditioned image diffusion
74+
6. Generate new edited images consistent with the reference sheet by leveraging an inpainting mask.
75+
76+
- Repeat step (6) for all cameras
77+
78+
7. Finally, the NeRF is fine-tuned on the edited images
79+
80+
### Reference Sheet Generation
81+
82+
<img src="https://arxiv.org/html/2401.01647v2/x4.png" width="100%" alt="Reference Sheet Generation" />
83+
84+
SIGNeRF uses a novel technique called reference sheet generation. We observe that the image
85+
diffusion model [ControlNet](https://github.com/lllyasviel/ControlNet) can already generate multiview consistent images of a scene without the need for iterative refinement like [Instruct-NeRF2NeRF](https://instruct-nerf2nerf.github.io/). While generating individual views sequentially introduces too much variation to integrate them into a consistent 3D model, arranging them in a grid of images that are processed by ControlNet in one pass significantly
86+
improves the multi-view consistency. Based on the depth maps rendered from the original NeRF
87+
scene we employ a depth-conditioned inpainting variant of ControlNet to generate such a reference sheet of the edited scene. A mask specifies the scene region where the generation should occur. This step gives a lot of control to the user. Different appearances can be produced by generating reference sheets with different seeds or prompts. The one sheet finally selected will directly determine the look of the final 3D scene.
88+
89+
If you want to learn more about the method, please read our [paper](https://arxiv.org/abs/2401.01647) or read the breakdown of the method in the [Radiance Fields article](https://radiancefields.com/controlnet-nerfs-signerf/).
90+
91+
## Related Work
92+
93+
SIGNeRF was inspired by the work of [Instruct-NeRF2NeRF](https://instruct-nerf2nerf.github.io/) which is also available in the [Nerfology](https://docs.nerf.studio/nerfology/methods/in2n.html) documentation.
94+
95+
## Authors
96+
97+
SIGNeRF was developed by [Jan-Niklas Dihlmann](https://jdihlmann.com) and [Andreas Engelhardt](https://aengelhardt.com/).

docs/quickstart/data_conventions.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ We use the OpenGL/Blender (and original NeRF) coordinate convention for cameras.
1212

1313
Our world space is oriented such that the up vector is +Z. The XY plane is parallel to the ground plane. In the viewer, you'll notice that red, green, and blue vectors correspond to X, Y, and Z respectively.
1414

15+
### Pixel coordinates
16+
17+
We assume coordinates correspond to the centers of pixels (e.g. generating a ray for pixel (0,0) will shoot the ray through the center of that pixel). This aligns more with graphics conventions, and is distinct from OpenCV where the corners are aligned with the pixel coordinate.
18+
1519
<hr>
1620

1721
## Dataset format

nerfstudio/cameras/camera_optimizers.py

+21-11
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from dataclasses import dataclass, field
2323
from typing import Literal, Optional, Type, Union
2424

25+
import numpy
2526
import torch
2627
import tyro
2728
from jaxtyping import Float, Int
@@ -151,15 +152,20 @@ def apply_to_raybundle(self, raybundle: RayBundle) -> None:
151152
raybundle.origins = raybundle.origins + correction_matrices[:, :3, 3]
152153
raybundle.directions = torch.bmm(correction_matrices[:, :3, :3], raybundle.directions[..., None]).squeeze()
153154

154-
def apply_to_camera(self, camera: Cameras) -> None:
155-
"""Apply the pose correction to the raybundle"""
156-
if self.config.mode != "off":
157-
assert camera.metadata is not None, "Must provide id of camera in its metadata"
158-
assert "cam_idx" in camera.metadata, "Must provide id of camera in its metadata"
159-
camera_idx = camera.metadata["cam_idx"]
160-
adj = self(torch.tensor([camera_idx], dtype=torch.long, device=camera.device)) # type: ignore
161-
adj = torch.cat([adj, torch.Tensor([0, 0, 0, 1])[None, None].to(adj)], dim=1)
162-
camera.camera_to_worlds = torch.bmm(camera.camera_to_worlds, adj)
155+
def apply_to_camera(self, camera: Cameras) -> torch.Tensor:
156+
"""Apply the pose correction to the world-to-camera matrix in a Camera object"""
157+
if self.config.mode == "off":
158+
return camera.camera_to_worlds
159+
160+
assert camera.metadata is not None, "Must provide id of camera in its metadata"
161+
if "cam_idx" not in camera.metadata:
162+
# Evalutaion cams?
163+
return camera.camera_to_worlds
164+
165+
camera_idx = camera.metadata["cam_idx"]
166+
adj = self(torch.tensor([camera_idx], dtype=torch.long, device=camera.device)) # type: ignore
167+
adj = torch.cat([adj, torch.Tensor([0, 0, 0, 1])[None, None].to(adj)], dim=1)
168+
return torch.bmm(camera.camera_to_worlds, adj)
163169

164170
def get_loss_dict(self, loss_dict: dict) -> None:
165171
"""Add regularization"""
@@ -176,8 +182,12 @@ def get_correction_matrices(self):
176182
def get_metrics_dict(self, metrics_dict: dict) -> None:
177183
"""Get camera optimizer metrics"""
178184
if self.config.mode != "off":
179-
metrics_dict["camera_opt_translation"] = self.pose_adjustment[:, :3].norm()
180-
metrics_dict["camera_opt_rotation"] = self.pose_adjustment[:, 3:].norm()
185+
trans = self.pose_adjustment[:, :3].detach().norm(dim=-1)
186+
rot = self.pose_adjustment[:, 3:].detach().norm(dim=-1)
187+
metrics_dict["camera_opt_translation_max"] = trans.max()
188+
metrics_dict["camera_opt_translation_mean"] = trans.mean()
189+
metrics_dict["camera_opt_rotation_mean"] = numpy.rad2deg(rot.mean().cpu())
190+
metrics_dict["camera_opt_rotation_max"] = numpy.rad2deg(rot.max().cpu())
181191

182192
def get_param_groups(self, param_groups: dict) -> None:
183193
"""Get camera optimizer parameters"""

nerfstudio/cameras/cameras.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -984,12 +984,15 @@ def get_intrinsics_matrices(self) -> Float[Tensor, "*num_cameras 3 3"]:
984984
return K
985985

986986
def rescale_output_resolution(
987-
self, scaling_factor: Union[Shaped[Tensor, "*num_cameras"], Shaped[Tensor, "*num_cameras 1"], float, int]
987+
self,
988+
scaling_factor: Union[Shaped[Tensor, "*num_cameras"], Shaped[Tensor, "*num_cameras 1"], float, int],
989+
scale_rounding_mode: str = "floor",
988990
) -> None:
989991
"""Rescale the output resolution of the cameras.
990992
991993
Args:
992994
scaling_factor: Scaling factor to apply to the output resolution.
995+
scale_rounding_mode: round down or round up when calculating the scaled image height and width
993996
"""
994997
if isinstance(scaling_factor, (float, int)):
995998
scaling_factor = torch.tensor([scaling_factor]).to(self.device).broadcast_to((self.cx.shape))
@@ -1006,5 +1009,14 @@ def rescale_output_resolution(
10061009
self.fy = self.fy * scaling_factor
10071010
self.cx = self.cx * scaling_factor
10081011
self.cy = self.cy * scaling_factor
1009-
self.height = (self.height * scaling_factor).to(torch.int64)
1010-
self.width = (self.width * scaling_factor).to(torch.int64)
1012+
if scale_rounding_mode == "floor":
1013+
self.height = (self.height * scaling_factor).to(torch.int64)
1014+
self.width = (self.width * scaling_factor).to(torch.int64)
1015+
elif scale_rounding_mode == "round":
1016+
self.height = torch.floor(0.5 + (self.height * scaling_factor)).to(torch.int64)
1017+
self.width = torch.floor(0.5 + (self.width * scaling_factor)).to(torch.int64)
1018+
elif scale_rounding_mode == "ceil":
1019+
self.height = torch.ceil(self.height * scaling_factor).to(torch.int64)
1020+
self.width = torch.ceil(self.width * scaling_factor).to(torch.int64)
1021+
else:
1022+
raise ValueError("Scale rounding mode must be 'floor', 'round' or 'ceil'.")

nerfstudio/configs/external_methods.py

+17
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515

1616
"""This file contains the configuration for external methods which are not included in this repository."""
17+
1718
import inspect
1819
import subprocess
1920
import sys
@@ -208,6 +209,22 @@ class ExternalMethod:
208209
)
209210
)
210211

212+
# SIGNeRF
213+
external_methods.append(
214+
ExternalMethod(
215+
"""[bold yellow]SIGNeRF[/bold yellow]
216+
For more information visit: https://docs.nerf.studio/nerfology/methods/signerf.html
217+
218+
To enable SIGNeRF, you must install it first by running:
219+
[grey]pip install git+https://github.com/cgtuebingen/SIGNeRF[/grey] and install Stable Diffusion Web UI see [grey]https://github.com/cgtuebingen/SIGNeRF?tab=readme-ov-file#installation[/grey]""",
220+
configurations=[
221+
("signerf", "SIGNeRF method (high quality) used in paper"),
222+
("signerf_nerfacto", "SIGNeRF method combined with Nerfacto (faster training less quality)"),
223+
],
224+
pip_package="git+https://github.com/cgtuebingen/SIGNeRF",
225+
)
226+
)
227+
211228

212229
@dataclass
213230
class ExternalMethodDummyTrainerConfig:

nerfstudio/configs/method_configs.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,10 @@
632632
},
633633
"quats": {"optimizer": AdamOptimizerConfig(lr=0.001, eps=1e-15), "scheduler": None},
634634
"camera_opt": {
635-
"optimizer": AdamOptimizerConfig(lr=1e-3, eps=1e-15),
636-
"scheduler": ExponentialDecaySchedulerConfig(lr_final=5e-5, max_steps=30000),
635+
"optimizer": AdamOptimizerConfig(lr=1e-4, eps=1e-15),
636+
"scheduler": ExponentialDecaySchedulerConfig(
637+
lr_final=5e-7, max_steps=30000, warmup_steps=1000, lr_pre_warmup=0
638+
),
637639
},
638640
},
639641
viewer=ViewerConfig(num_rays_per_chunk=1 << 15),
@@ -684,8 +686,10 @@
684686
},
685687
"quats": {"optimizer": AdamOptimizerConfig(lr=0.001, eps=1e-15), "scheduler": None},
686688
"camera_opt": {
687-
"optimizer": AdamOptimizerConfig(lr=1e-3, eps=1e-15),
688-
"scheduler": ExponentialDecaySchedulerConfig(lr_final=5e-5, max_steps=30000),
689+
"optimizer": AdamOptimizerConfig(lr=1e-4, eps=1e-15),
690+
"scheduler": ExponentialDecaySchedulerConfig(
691+
lr_final=5e-7, max_steps=30000, warmup_steps=1000, lr_pre_warmup=0
692+
),
689693
},
690694
},
691695
viewer=ViewerConfig(num_rays_per_chunk=1 << 15),

nerfstudio/data/datamanagers/full_images_datamanager.py

+10
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ def _undistort_image(
347347
0,
348348
]
349349
)
350+
# because OpenCV expects the pixel coord to be top-left, we need to shift the principal point by 0.5
351+
# see https://github.com/nerfstudio-project/nerfstudio/issues/3048
352+
K[0, 2] = K[0, 2] - 0.5
353+
K[1, 2] = K[1, 2] - 0.5
350354
if np.any(distortion_params):
351355
newK, roi = cv2.getOptimalNewCameraMatrix(K, distortion_params, (image.shape[1], image.shape[0]), 0)
352356
image = cv2.undistort(image, K, distortion_params, None, newK) # type: ignore
@@ -367,9 +371,13 @@ def _undistort_image(
367371
mask = torch.from_numpy(mask).bool()
368372
if len(mask.shape) == 2:
369373
mask = mask[:, :, None]
374+
newK[0, 2] = newK[0, 2] + 0.5
375+
newK[1, 2] = newK[1, 2] + 0.5
370376
K = newK
371377

372378
elif camera.camera_type.item() == CameraType.FISHEYE.value:
379+
K[0, 2] = K[0, 2] - 0.5
380+
K[1, 2] = K[1, 2] - 0.5
373381
distortion_params = np.array(
374382
[distortion_params[0], distortion_params[1], distortion_params[2], distortion_params[3]]
375383
)
@@ -388,6 +396,8 @@ def _undistort_image(
388396
mask = torch.from_numpy(mask).bool()
389397
if len(mask.shape) == 2:
390398
mask = mask[:, :, None]
399+
newK[0, 2] = newK[0, 2] + 0.5
400+
newK[1, 2] = newK[1, 2] + 0.5
391401
K = newK
392402
elif camera.camera_type.item() == CameraType.FISHEYE624.value:
393403
fisheye624_params = torch.cat(

nerfstudio/data/datamanagers/parallel_datamanager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ def __init__(
9393
self.exclude_batch_keys_from_device = self.dataset.exclude_batch_keys_from_device
9494
self.pixel_sampler = pixel_sampler
9595
self.ray_generator = RayGenerator(self.dataset.cameras)
96-
self.cache_images()
9796

9897
def run(self):
9998
"""Append out queue in parallel with ray bundles and batches."""
99+
self.cache_images()
100100
while True:
101101
batch = self.pixel_sampler.sample(self.img_data)
102102
ray_indices = batch["indices"]

0 commit comments

Comments
 (0)