-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can nerfacc support mipnerf and mipnerf360? #88
Comments
Hi we took into consider the mip-nerf formulation when designing nerfacc, so it should be fairly easy to work with mipnerf. Specifically, for mipnerf, each ray would have rays_o: Tensor = ... # ray origins. (n_rays, 3)
rays_d: Tensor = ... # ray normalized directions. (n_rays, 3)
rays_radii: Tensor = ... # ray radius on image plane. (n_rays,) And you can compute the covariance within the def sigma_fn(
t_starts: Tensor, t_ends:Tensor, ray_indices: Tensor
) -> Tensor:
""" Query density values from a user-defined radiance field.
:params t_starts: Start of the sample interval along the ray. (n_samples, 1).
:params t_ends: End of the sample interval along the ray. (n_samples, 1).
:params ray_indices: Ray indices that each sample belongs to. (n_samples,).
:returns The post-activation density values. (n_samples, 1).
"""
t_origins = rays_o[ray_indices] # (n_samples, 3)
t_dirs = rays_d[ray_indices] # (n_samples, 3)
t_radii = rays_radii[ray_indices] # (n_samples,)
mean, cov = cylinder_to_gaussian(t_starts, t_ends, t_origins, t_dirs, t_radii)
sigmas = radiance_field.query_density(mean, cov)
return sigmas # (n_samples, 1) Same for the |
For the def occ_eval_fn(x):
# Randomly sample cameras for each point. we want the
# occupancy grid to cache the maximum possible opacity at
# location x. For mip-nerf, the density is "camera-dependent".
camera_ids = torch.randint(
0, len(train_dataset), (x.shape[0],), device=device
)
cameras = train_dataset.cameras[camera_ids]
# compute some infos based on the camera.
t_origins, t_dirs, t_radii = compute_sample_infos(cameras, x)
# compute sample interval based on the camera.
t_starts, t_ends = compute_sample_interval(cameras, x)
# compute mean, cov of the samples.
mean, cov = cylinder_to_gaussian(t_starts, t_ends, t_origins, t_dirs, t_radii)
# compute occupancy
density = radiance_field.query_density(mean, cov)
return density * (t_ends - t_starts) For your reference, there is a demo of compute camera-dependent For mip-nerf, it would be a bit more complicated but the idea is the same. |
Thank you very much! I have one more question for updating occupancy grid. In In my mind, mipnerf use Multivariate Gaussian distribution to simulate the coordinate distribution inside a conical frustum. Since we are focusing voxel grid (or cube) when updating |
Hi! I think that is an interesting point. It might be ok to just use the mean and cov for the grid cell. But in that case you are essentially use the Though the way we use Anyway I would be very curious to see how things going with mipnerf if you plan to try it out! |
Thank you! I think you are right. The average occupancy might not be accurate enough to indicate which grid cell can be skipped. This is just an idea came to me when reading your code snippet and I'm going to try the method you provided first. |
Hi, thanks for your great framework. I'm trying to use nerfacc to accelerate
mipnerf
andmipnerf360
, but this seems harder than I thought, since these two models sample cones instead of points, and need compute covariance after sampling.I'll be very appreciate it if you can give me some hints!
The text was updated successfully, but these errors were encountered: