Skip to content

Commit

Permalink
[master] Update obsolete ops and fix document
Browse files Browse the repository at this point in the history
  • Loading branch information
hangg7 committed Jan 19, 2023
1 parent a7a9b8b commit a5a401c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 2 additions & 3 deletions nerfvis/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ def add_nerf(self,
:param eval_fn:
- If :code:`use_dirs=False`: NeRF function taking a batch of points :code:`(B, 3)` and returning :code:`(rgb (B, 3), sigma (B, 1))` after activation applied.
- If :code:`use_dirs=True` then this function should take points :code:`(B, 1, 3)` and kwarg 'dirs' :code:`(1, sh_proj_sample_count, 3)`; it should return :code:`(rgb (B, sh_proj_sample_count, 3), sigma (B, 1))` sigma activation
- If :code:`use_dirs=True` then this function should take points :code:`(B, 1, 3)` and kwarg 'dirs' :code:`(1, sh_proj_sample_count, 3)`; it should return :code:`(rgb (B, sh_proj_sample_count, 3), sigma (B, sh_proj_sample_count, 1))` sigma activation
should be applied but rgb must NOT have activation applied for SH projection to work correctly.
:param center: float or (3,), xyz center of volume to discretize
Expand Down Expand Up @@ -984,7 +984,7 @@ def _calculate_grid_weights(sigmas, c2w, focal_length, image_width, image_height
"image_height should be provided to set_nerf to use weight thresholding"
grid_weights = _calculate_grid_weights(rgb_sigma[..., -1:], c2w.float(), focal_length, image_width, image_height)
mask = grid_weights.reshape(-1) >= weight_thresh
grid = grid[mask]
grid = grid[mask.cpu()]
rgb_sigma = rgb_sigma[mask]
del mask
assert grid.shape[0] > 0, "This NeRF is completely empty! Make sure you set the bounds reasonably"
Expand Down Expand Up @@ -1314,4 +1314,3 @@ def embed(self,
**kwargs)
html_file = os.path.join(dirname_rel, embed_name)
display(IFrame(html_file, width, height))

3 changes: 1 addition & 2 deletions nerfvis/utils/sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def project_function_sparse(
sample_count, coeff_count) # [sample_count, coeff_count]
func_value = func_value.transpose(0, 1).reshape(
sample_count, batch_size * C) # [sample_count, batch_size * C]
soln = torch.lstsq(func_value, basis_vals).solution[:basis_vals.size(1)]
soln = torch.linalg.lstsq(basis_vals, func_value).solution
soln = soln.T.reshape(batch_size, -1)
others = others[:, :1, :]
others = others.reshape(batch_size, -1)
Expand All @@ -370,4 +370,3 @@ def sphfunc_one(x):

coeffs, others = project_function_sparse(1, sphfunc_one, 10)
print(coeffs)

0 comments on commit a5a401c

Please sign in to comment.