Skip to content

Commit

Permalink
get rid of gsplat legacy dep (#3386)
Browse files Browse the repository at this point in the history
Co-authored-by: Ruilong Li <[email protected]>
  • Loading branch information
liruilong940607 and Ruilong Li authored Aug 26, 2024
1 parent 792c5fa commit 1f2344a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion nerfstudio/models/splatfacto.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import numpy as np
import torch
from gsplat.cuda_legacy._torch_impl import quat_to_rotmat

try:
from gsplat.rendering import rasterization
Expand All @@ -47,6 +46,26 @@
from nerfstudio.utils.rich_utils import CONSOLE


def quat_to_rotmat(quat):
assert quat.shape[-1] == 4, quat.shape
w, x, y, z = torch.unbind(quat, dim=-1)
mat = torch.stack(
[
1 - 2 * (y**2 + z**2),
2 * (x * y - w * z),
2 * (x * z + w * y),
2 * (x * y + w * z),
1 - 2 * (x**2 + z**2),
2 * (y * z - w * x),
2 * (x * z - w * y),
2 * (y * z + w * x),
1 - 2 * (x**2 + y**2),
],
dim=-1,
)
return mat.reshape(quat.shape[:-1] + (3, 3))


def random_quat_tensor(N):
"""
Defines a random quaternion tensor of shape (N, 4)
Expand Down

0 comments on commit 1f2344a

Please sign in to comment.