mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-01 13:28:59 +08:00
Speedup eval and training with better data management (#492)
move to tensors to gpu earlier
This commit is contained in:
1 parent
96e1f2a698
commit
a43776d76d
5 files changed
+13
-12
No files matched your search
@@ -171,6 +171,9 @@ class Cameras:
|
||||
Rays for the given camera indices and coords.
|
||||
"""
|
||||
|
||||
if isinstance(camera_indices, torch.Tensor):
|
||||
camera_indices = camera_indices.to(self.device)
|
||||
|
||||
if coords is None:
|
||||
coords = self.get_image_coords().to(self.device)
|
||||
|
||||
@@ -237,7 +240,7 @@ class Cameras:
|
||||
if not isinstance(camera_indices, torch.Tensor):
|
||||
ray_bundle_camera_indices = torch.Tensor([camera_indices]).broadcast_to(pixel_area.shape).to(self.device)
|
||||
else:
|
||||
ray_bundle_camera_indices = camera_indices
|
||||
ray_bundle_camera_indices = camera_indices.view(pixel_area.shape)
|
||||
|
||||
return RayBundle(
|
||||
origins=origins,
|
||||
|
||||
@@ -113,7 +113,7 @@ class RaySamples(TensorDataclass):
|
||||
# mip-nerf version of transmittance calculation:
|
||||
transmittance = torch.cumsum(delta_density[..., :-1, :], dim=-2)
|
||||
transmittance = torch.cat(
|
||||
[torch.zeros((*transmittance.shape[:1], 1, 1)).to(densities.device), transmittance], dim=-2
|
||||
[torch.zeros((*transmittance.shape[:1], 1, 1), device=densities.device), transmittance], dim=-2
|
||||
)
|
||||
transmittance = torch.exp(-transmittance) # [..., "num_samples"]
|
||||
|
||||
|
||||
Reference in new issue
Block a user