Commit a0ab0265 authored by Ruilong Li's avatar Ruilong Li
Browse files

update steps_counter to int

parent 9bddde48
...@@ -69,14 +69,15 @@ def render_image(radiance_field, rays, render_bkgd, render_step_size): ...@@ -69,14 +69,15 @@ def render_image(radiance_field, rays, render_bkgd, render_step_size):
) )
results.append(chunk_results) results.append(chunk_results)
rgb, depth, acc, counter, compact_counter = [ rgb, depth, acc, counter, compact_counter = [
torch.cat(r, dim=0) for r in zip(*results) torch.cat(r, dim=0) if isinstance(r[0], torch.Tensor) else r
for r in zip(*results)
] ]
return ( return (
rgb.view((*rays_shape[:-1], -1)), rgb.view((*rays_shape[:-1], -1)),
depth.view((*rays_shape[:-1], -1)), depth.view((*rays_shape[:-1], -1)),
acc.view((*rays_shape[:-1], -1)), acc.view((*rays_shape[:-1], -1)),
counter.sum(), sum(counter),
compact_counter.sum(), sum(compact_counter),
) )
...@@ -191,7 +192,7 @@ if __name__ == "__main__": ...@@ -191,7 +192,7 @@ if __name__ == "__main__":
) )
num_rays = len(pixels) num_rays = len(pixels)
num_rays = int( num_rays = int(
num_rays * (TARGET_SAMPLE_BATCH_SIZE / float(compact_counter.item())) num_rays * (TARGET_SAMPLE_BATCH_SIZE / float(compact_counter))
) )
train_dataset.update_num_rays(num_rays) train_dataset.update_num_rays(num_rays)
alive_ray_mask = acc.squeeze(-1) > 0 alive_ray_mask = acc.squeeze(-1) > 0
...@@ -210,7 +211,7 @@ if __name__ == "__main__": ...@@ -210,7 +211,7 @@ if __name__ == "__main__":
f"elapsed_time={elapsed_time:.2f}s (data={data_time:.2f}s) | {step=} | " f"elapsed_time={elapsed_time:.2f}s (data={data_time:.2f}s) | {step=} | "
f"loss={loss:.5f} | " f"loss={loss:.5f} | "
f"alive_ray_mask={alive_ray_mask.long().sum():d} | " f"alive_ray_mask={alive_ray_mask.long().sum():d} | "
f"counter={counter.item():d} | compact_counter={compact_counter.item():d} | num_rays={len(pixels):d} " f"counter={counter:d} | compact_counter={compact_counter:d} | num_rays={len(pixels):d} "
) )
# if time.time() - tic > 300: # if time.time() - tic > 300:
......
...@@ -23,6 +23,12 @@ def volumetric_rendering( ...@@ -23,6 +23,12 @@ def volumetric_rendering(
"""A *fast* version of differentiable volumetric rendering.""" """A *fast* version of differentiable volumetric rendering."""
n_rays = rays_o.shape[0] n_rays = rays_o.shape[0]
rays_o = rays_o.contiguous()
rays_d = rays_d.contiguous()
scene_aabb = scene_aabb.contiguous()
scene_occ_binary = scene_occ_binary.contiguous()
render_bkgd = render_bkgd.contiguous()
# get packed samples from ray marching & occupancy check. # get packed samples from ray marching & occupancy check.
with torch.no_grad(): with torch.no_grad():
( (
...@@ -45,7 +51,7 @@ def volumetric_rendering( ...@@ -45,7 +51,7 @@ def volumetric_rendering(
frustum_positions = ( frustum_positions = (
frustum_origins + frustum_dirs * (frustum_starts + frustum_ends) / 2.0 frustum_origins + frustum_dirs * (frustum_starts + frustum_ends) / 2.0
) )
steps_counter = packed_info[:, -1].sum(0, keepdim=True) steps_counter = frustum_origins.shape[0]
# compat the samples thru volumetric rendering # compat the samples thru volumetric rendering
with torch.no_grad(): with torch.no_grad():
...@@ -64,7 +70,7 @@ def volumetric_rendering( ...@@ -64,7 +70,7 @@ def volumetric_rendering(
frustum_positions, frustum_positions,
frustum_dirs, frustum_dirs,
) )
compact_steps_counter = compact_packed_info[:, -1].sum(0, keepdim=True) compact_steps_counter = compact_frustum_positions.shape[0]
# network # network
compact_query_results = query_fn(compact_frustum_positions, compact_frustum_dirs) compact_query_results = query_fn(compact_frustum_positions, compact_frustum_dirs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment