mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-06 07:48:50 +08:00
nerf-w and semantic-nerf initial implementations (#73)
* initial nerfw code * nerfw should be implmented correctly now * semantic nerf in progress. data loader is too slow and not clean right now * added implementation of semantic nerf * mend
This commit is contained in:
1 parent
97c9fe2541
commit
1c1a58c4e5
22 files changed
+725
-92
No files matched your search
@@ -17,6 +17,8 @@ class RendererOutputs:
|
||||
density: TensorType["num_rays", 1] = None
|
||||
accumulation: TensorType["num_rays", 1] = None
|
||||
depth: TensorType["num_rays", 1] = None
|
||||
uncertainty: TensorType["num_rays", 1] = None
|
||||
semantics: TensorType["num_rays", "num_classes"] = None
|
||||
|
||||
|
||||
class RGBRenderer(nn.Module):
|
||||
@@ -116,3 +118,37 @@ class DepthRenderer(nn.Module):
|
||||
return RendererOutputs(depth=depth[..., None])
|
||||
|
||||
raise NotImplementedError(f"Method {self.method} not implemented")
|
||||
|
||||
|
||||
class UncertaintyRenderer(nn.Module):
|
||||
"""Calculate uncertainty along the ray."""
|
||||
|
||||
@classmethod
|
||||
def forward(
|
||||
cls, betas: TensorType[..., "num_samples", 1], weights: TensorType[..., "num_samples"]
|
||||
) -> RendererOutputs:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
betas (TensorType[..., "num_samples", 1]): _description_
|
||||
weights (TensorType[..., "num_samples"]): _description_
|
||||
|
||||
Returns:
|
||||
RendererOutputs: _description_
|
||||
"""
|
||||
uncertainty = torch.sum(weights[..., None] * betas, dim=-2)
|
||||
renderer_outputs = RendererOutputs(uncertainty=uncertainty)
|
||||
return renderer_outputs
|
||||
|
||||
|
||||
class SemanticRenderer(nn.Module):
|
||||
"""Calculate semantics along the ray."""
|
||||
|
||||
@classmethod
|
||||
def forward(
|
||||
cls, semantics: TensorType[..., "num_samples", "num_classes"], weights: TensorType[..., "num_samples"]
|
||||
) -> RendererOutputs:
|
||||
"""_summary_"""
|
||||
sem = torch.sum(weights[..., None] * semantics, dim=-2)
|
||||
renderer_outputs = RendererOutputs(semantics=sem)
|
||||
return renderer_outputs
|
||||
Reference in new issue
Block a user