mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-30 21:09:58 +08:00
add time (#1391)
* add time * fix black --------- Co-authored-by: LcDog <12553253+LcDog@users.noreply.github.com>
This commit is contained in:
1 parent
df784e96e7
commit
b653eef91c
3 files changed
+7
-4
No files matched your search
@@ -100,12 +100,16 @@ def get_spiral_path(
|
|||||||
new_c2ws.append(c2wh[:3, :4])
|
new_c2ws.append(c2wh[:3, :4])
|
||||||
new_c2ws = torch.stack(new_c2ws, dim=0)
|
new_c2ws = torch.stack(new_c2ws, dim=0)
|
||||||
|
|
||||||
|
times = None
|
||||||
|
if camera.times is not None:
|
||||||
|
times = torch.linspace(0, 1, steps)[:, None]
|
||||||
return Cameras(
|
return Cameras(
|
||||||
fx=camera.fx[0],
|
fx=camera.fx[0],
|
||||||
fy=camera.fy[0],
|
fy=camera.fy[0],
|
||||||
cx=camera.cx[0],
|
cx=camera.cx[0],
|
||||||
cy=camera.cy[0],
|
cy=camera.cy[0],
|
||||||
camera_to_worlds=new_c2ws,
|
camera_to_worlds=new_c2ws,
|
||||||
|
times=times,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ class Cameras(TensorDataclass):
|
|||||||
c_x_y: cx or cy for when h_w == None
|
c_x_y: cx or cy for when h_w == None
|
||||||
"""
|
"""
|
||||||
if isinstance(h_w, int):
|
if isinstance(h_w, int):
|
||||||
h_w = torch.Tensor([h_w]).to(torch.int64).to(self.device)
|
h_w = torch.as_tensor([h_w]).to(torch.int64).to(self.device)
|
||||||
elif isinstance(h_w, torch.Tensor):
|
elif isinstance(h_w, torch.Tensor):
|
||||||
assert not torch.is_floating_point(h_w), f"height and width tensor must be of type int, not: {h_w.dtype}"
|
assert not torch.is_floating_point(h_w), f"height and width tensor must be of type int, not: {h_w.dtype}"
|
||||||
h_w = h_w.to(torch.int64).to(self.device)
|
h_w = h_w.to(torch.int64).to(self.device)
|
||||||
@@ -238,7 +238,7 @@ class Cameras(TensorDataclass):
|
|||||||
h_w = h_w.unsqueeze(-1)
|
h_w = h_w.unsqueeze(-1)
|
||||||
# assert torch.all(h_w == h_w.view(-1)[0]), "Batched cameras of different h, w will be allowed in the future."
|
# assert torch.all(h_w == h_w.view(-1)[0]), "Batched cameras of different h, w will be allowed in the future."
|
||||||
elif h_w is None:
|
elif h_w is None:
|
||||||
h_w = torch.Tensor((c_x_y * 2).to(torch.int64).to(self.device))
|
h_w = torch.as_tensor((c_x_y * 2)).to(torch.int64).to(self.device)
|
||||||
else:
|
else:
|
||||||
raise ValueError("Height must be an int, tensor, or None, received: " + str(type(h_w)))
|
raise ValueError("Height must be an int, tensor, or None, received: " + str(type(h_w)))
|
||||||
return h_w
|
return h_w
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ class TemporalGridEncodeFunc(Function):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@custom_bwd
|
@custom_bwd
|
||||||
def backward(ctx, grad):
|
def backward(ctx, grad):
|
||||||
|
|
||||||
inputs, temporal_row_index, embeddings, offsets, dy_dx = ctx.saved_tensors
|
inputs, temporal_row_index, embeddings, offsets, dy_dx = ctx.saved_tensors
|
||||||
B, D, grid_channel, C, L, S, H, gridtype = ctx.dims
|
B, D, grid_channel, C, L, S, H, gridtype = ctx.dims
|
||||||
align_corners = ctx.align_corners
|
align_corners = ctx.align_corners
|
||||||
@@ -336,7 +335,7 @@ class TemporalGridEncoder(nn.Module):
|
|||||||
"""
|
"""
|
||||||
outputs = TemporalGridEncodeFunc.apply(
|
outputs = TemporalGridEncodeFunc.apply(
|
||||||
xyz,
|
xyz,
|
||||||
self.get_temporal_index(time[:, 0]),
|
self.get_temporal_index(time[:, 0].float()),
|
||||||
self.embeddings,
|
self.embeddings,
|
||||||
self.offsets,
|
self.offsets,
|
||||||
self.per_level_scale,
|
self.per_level_scale,
|
||||||
|
|||||||
Reference in new issue
Block a user