mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-01 21:39:06 +08:00
CPU usage improvement and minor changes (#108)
* cpu fixes, masking logic but commented out, nerfw and semanticnerf in progress * pylint
This commit is contained in:
1 parent
5e9d064db6
commit
3226a1c989
18 files changed
+118
-67
No files matched your search
@@ -106,7 +106,7 @@ class Camera:
|
||||
"""
|
||||
height = self.get_image_height()
|
||||
width = self.get_image_width()
|
||||
intrinsics = self.get_intrinsics().unsqueeze(0).repeat(height, height, 1) # (num_rays, num_intrinsics_params)
|
||||
intrinsics = self.get_intrinsics().unsqueeze(0).repeat(height, width, 1) # (num_rays, num_intrinsics_params)
|
||||
camera_to_world = self.camera_to_world.unsqueeze(0).repeat(height, width, 1, 1) # (num_rays, 3, 4)
|
||||
coords = self.get_image_coords()
|
||||
ray_bundle = self.generate_rays(intrinsics, camera_to_world, coords)
|
||||
|
||||
@@ -89,12 +89,19 @@ class RaySamples:
|
||||
delta_density = self.deltas * densities[..., 0]
|
||||
alphas = 1 - torch.exp(-delta_density)
|
||||
|
||||
# mip-nerf version of transmittance calculation:
|
||||
transmittance = torch.cumsum(delta_density[..., :-1], dim=-1)
|
||||
transmittance = torch.cat(
|
||||
[torch.zeros((*transmittance.shape[:1], 1)).to(densities.device), transmittance], axis=-1
|
||||
)
|
||||
transmittance = torch.exp(-transmittance) # [..., "num_samples"]
|
||||
|
||||
# most nerf codebases do the following:
|
||||
# transmittance = torch.cat(
|
||||
# [torch.ones((*alphas.shape[:1], 1)).to(densities.device), 1.0 - alphas + 1e-10], dim=-1
|
||||
# )
|
||||
# transmittance = torch.cumprod(transmittance, dim=-1)[..., :-1] # [..., "num_samples"]
|
||||
|
||||
weights = alphas * transmittance # [..., "num_samples"]
|
||||
|
||||
return weights
|
||||
|
||||
Reference in new issue
Block a user