From 5e66596e1839850e668a5252e7fe5b8fb74e80f5 Mon Sep 17 00:00:00 2001 From: bennyguo Date: Tue, 1 Nov 2022 10:59:01 +0800 Subject: [PATCH] Switch to use the official nerfacc (add support for alpha rendering from v0.2.2). --- README.md | 1 - models/nerf.py | 2 +- models/neus.py | 8 ++++---- requirements.txt | 1 + 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 36ef05bc..c2338a0e 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,6 @@ This repository contains a concise and extensible implementation of NeRF and Neu ### Environments - Install PyTorch>=1.10 [here](https://pytorch.org/get-started/locally/) based the package management tool you used and your cuda version (older PyTorch versions may work but have not been tested) - Install tiny-cuda-nn PyTorch extension: `pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch` -- Install my fork of nerfacc (with support for NeuS training): `pip install git+https://github.com/bennyguo/nerfacc/` - `pip install -r requirements.txt` diff --git a/models/nerf.py b/models/nerf.py index b10d8aad..6e9154d4 100644 --- a/models/nerf.py +++ b/models/nerf.py @@ -73,10 +73,10 @@ def rgb_sigma_fn(t_starts, t_ends, ray_indices): ) rgb, opacity, depth = rendering( - rgb_sigma_fn, packed_info, t_starts, t_ends, + rgb_sigma_fn=rgb_sigma_fn, render_bkgd=self.background_color ) diff --git a/models/neus.py b/models/neus.py index 886cbbda..b21cd82b 100644 --- a/models/neus.py +++ b/models/neus.py @@ -6,7 +6,7 @@ from models.base import BaseModel from models.utils import chunk_batch from systems.utils import update_module_step -from nerfacc import ContractionType, OccupancyGrid, ray_marching_alpha, rendering_alpha +from nerfacc import ContractionType, OccupancyGrid, ray_marching, rendering class VarianceNetwork(nn.Module): @@ -121,7 +121,7 @@ def rgb_alpha_fn(t_starts, t_ends, ray_indices): return rgb, alpha[...,None] with torch.no_grad(): - packed_info, t_starts, t_ends = ray_marching_alpha( + packed_info, t_starts, t_ends = ray_marching( rays_o, rays_d, scene_aabb=self.scene_aabb, grid=self.occupancy_grid if self.config.grid_prune else None, @@ -133,11 +133,11 @@ def rgb_alpha_fn(t_starts, t_ends, ray_indices): alpha_thre=0.0 ) - rgb, opacity, depth = rendering_alpha( - rgb_alpha_fn, + rgb, opacity, depth = rendering( packed_info, t_starts, t_ends, + rgb_alpha_fn=rgb_alpha_fn, render_bkgd=self.background_color, ) diff --git a/requirements.txt b/requirements.txt index 58c29879..48e175b8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ pytorch-lightning==1.7.7 omegaconf==2.2.3 +nerfacc==0.2.2 matplotlib opencv-python imageio