mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 06:49:13 +08:00
All lerf-changes moved to projects-lerf, except viewer changes
This commit is contained in:
1 parent
18208f7aaa
commit
a87b7c3b53
6 files changed
+52
-43
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import torch
|
||||
from torch import nn
|
||||
from torchtyping import TensorType
|
||||
|
||||
class CLIPRenderer(nn.Module):
|
||||
"""Calculate CLIP embeddings along ray."""
|
||||
|
||||
@classmethod
|
||||
def forward(
|
||||
cls,
|
||||
embeds: TensorType["bs":..., "num_samples", "num_classes"],
|
||||
weights: TensorType["bs":..., "num_samples", 1],
|
||||
) -> TensorType["bs":..., "num_classes"]:
|
||||
"""Calculate semantics along the ray."""
|
||||
output = torch.sum(weights * embeds, dim=-2)
|
||||
output = output / torch.linalg.norm(output, dim=-1, keepdim=True)
|
||||
return output
|
||||
|
||||
|
||||
class MeanRenderer(nn.Module):
|
||||
"""Calculate average of embeddings along ray."""
|
||||
|
||||
@classmethod
|
||||
def forward(
|
||||
cls,
|
||||
embeds: TensorType["bs":..., "num_samples", "num_classes"],
|
||||
weights: TensorType["bs":..., "num_samples", 1],
|
||||
) -> TensorType["bs":..., "num_classes"]:
|
||||
"""Calculate semantics along the ray."""
|
||||
output = torch.sum(weights * embeds, dim=-2)
|
||||
return output
|
||||
Reference in new issue
Block a user