mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-07 00:09:14 +08:00
Refactoring (data loading, semantic-nerf/nerf-w fixes, ...) (#8)
* in progress. camera_indices broken * faster dataloader. starting on pixel sampler logic * imagesampler and pixelsampler * lint and black * continuing merge * pytest working * fixed docs * docs * minor changes
This commit is contained in:
1 parent
1f189b3e54
commit
146332cfb6
50 files changed
+914
-831
No files matched your search
@@ -74,7 +74,12 @@ class RaySamples:
|
||||
def to_point_samples(self) -> PointSamples:
|
||||
"""Convert to PointSamples instance and return."""
|
||||
# TODO: make this more interpretable
|
||||
return PointSamples(positions=self.positions, directions=self.directions, valid_mask=self.valid_mask)
|
||||
return PointSamples(
|
||||
positions=self.positions,
|
||||
directions=self.directions,
|
||||
camera_indices=self.camera_indices,
|
||||
valid_mask=self.valid_mask,
|
||||
)
|
||||
|
||||
def get_weights(self, densities: TensorType[..., "num_samples", 1]) -> TensorType[..., "num_samples"]:
|
||||
"""Return weights based on predicted densities
|
||||
@@ -139,7 +144,7 @@ class RayBundle:
|
||||
"""
|
||||
self.origins = self.origins.to(device)
|
||||
self.directions = self.directions.to(device)
|
||||
if not isinstance(self.camera_indices, type(None)):
|
||||
if is_not_none(self.camera_indices):
|
||||
self.camera_indices = self.camera_indices.to(device)
|
||||
|
||||
def set_camera_indices(self, camera_index: int) -> None:
|
||||
@@ -227,7 +232,7 @@ class RayBundle:
|
||||
dists = torch.cat([dists, dists[..., -1:]], -1) # [N_rays, N_samples]
|
||||
deltas = dists * torch.norm(self.directions[..., None, :], dim=-1)
|
||||
|
||||
if self.camera_indices is not None:
|
||||
if is_not_none(self.camera_indices):
|
||||
camera_indices = self.camera_indices.unsqueeze(1).repeat(1, positions.shape[1])
|
||||
else:
|
||||
camera_indices = None
|
||||
|
||||
Reference in new issue
Block a user