Skip to content

Commit

Permalink
bugfix: raymarching when not forcing all rays
Browse files Browse the repository at this point in the history
  • Loading branch information
ashawkey committed Sep 11, 2022
1 parent 3c14ad5 commit 6d5016f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ data/
trial*/
.vs/

volsdf/
**volsdf*
tensorf/
**tensorf*
#**dnerf*
#dnerf/
dnerf/network_rf.py
dnerf/network_basis_perpoint.py

**neus*
neus/
2 changes: 1 addition & 1 deletion dnerf/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def mark_untrained_grid(self, poses, intrinsic, S=64):
# mark untrained grid as -1
self.density_grid[count.unsqueeze(0).expand_as(self.density_grid) == 0] = -1

#print(f'[mark untrained grid] {(count == 0).sum()} from {resolution ** 3 * self.cascade}')
print(f'[mark untrained grid] {(count == 0).sum()} from {self.grid_size ** 3 * self.cascade}')

@torch.no_grad()
def update_extra_state(self, decay=0.95, S=128):
Expand Down
2 changes: 1 addition & 1 deletion nerf/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def mark_untrained_grid(self, poses, intrinsic, S=64):
# mark untrained grid as -1
self.density_grid[count == 0] = -1

#print(f'[mark untrained grid] {(count == 0).sum()} from {resolution ** 3 * self.cascade}')
print(f'[mark untrained grid] {(count == 0).sum()} from {self.grid_size ** 3 * self.cascade}')

@torch.no_grad()
def update_extra_state(self, decay=0.95, S=128):
Expand Down
4 changes: 2 additions & 2 deletions nerf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ def train_step(self, data):
else:
gt_rgb = images

# outputs = self.model.render(rays_o, rays_d, staged=False, bg_color=bg_color, perturb=True, force_all_rays=False if self.opt.patch_size == 1 else True, **vars(self.opt))
outputs = self.model.render(rays_o, rays_d, staged=False, bg_color=bg_color, perturb=True, force_all_rays=True, **vars(self.opt))
outputs = self.model.render(rays_o, rays_d, staged=False, bg_color=bg_color, perturb=True, force_all_rays=False if self.opt.patch_size == 1 else True, **vars(self.opt))
# outputs = self.model.render(rays_o, rays_d, staged=False, bg_color=bg_color, perturb=True, force_all_rays=True, **vars(self.opt))

pred_rgb = outputs['image']

Expand Down
6 changes: 3 additions & 3 deletions raymarching/src/raymarching.cu
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ __global__ void kernel_march_rays_train(
rays[ray_index * 3 + 2] = num_steps;

if (num_steps == 0) return;
if (point_index + num_steps >= M) return;
if (point_index + num_steps > M) return;

xyzs += point_index * 3;
dirs += point_index * 3;
Expand Down Expand Up @@ -518,7 +518,7 @@ __global__ void kernel_composite_rays_train_forward(
uint32_t num_steps = rays[n * 3 + 2];

// empty ray, or ray that exceed max step count.
if (num_steps == 0 || offset + num_steps >= M) {
if (num_steps == 0 || offset + num_steps > M) {
weights_sum[index] = 0;
depth[index] = 0;
image[index * 3] = 0;
Expand Down Expand Up @@ -621,7 +621,7 @@ __global__ void kernel_composite_rays_train_backward(
uint32_t offset = rays[n * 3 + 1];
uint32_t num_steps = rays[n * 3 + 2];

if (num_steps == 0 || offset + num_steps >= M) return;
if (num_steps == 0 || offset + num_steps > M) return;

grad_weights_sum += index;
grad_image += index * 3;
Expand Down

0 comments on commit 6d5016f

Please sign in to comment.