Spaces:
Running
on
L40S
Running
on
L40S
Upload ./svrm/ldm/vis_util.py with huggingface_hub
Browse files- svrm/ldm/vis_util.py +10 -1
svrm/ldm/vis_util.py
CHANGED
@@ -26,6 +26,13 @@ from pytorch3d.renderer import (
|
|
26 |
BlendParams,
|
27 |
)
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
def render_func(
|
31 |
obj_filename,
|
@@ -46,7 +53,9 @@ def render_func(
|
|
46 |
rgb: if set true, will convert result to rgb image/frame
|
47 |
'''
|
48 |
# load mesh
|
49 |
-
mesh = load_objs_as_meshes([obj_filename], device=device)
|
|
|
|
|
50 |
meshes = mesh.extend(n_views)
|
51 |
|
52 |
if azim is None:
|
|
|
26 |
BlendParams,
|
27 |
)
|
28 |
|
29 |
+
import trimesh
|
30 |
+
def load_glb_as_meshes(glb_filename, device):
|
31 |
+
mesh = trimesh.load(glb_filename, force='mesh')
|
32 |
+
vertices = torch.tensor(mesh.vertices, dtype=torch.float32).to(device)
|
33 |
+
faces = torch.tensor(mesh.faces, dtype=torch.int64).to(device)
|
34 |
+
return Meshes(verts=[vertices], faces=[faces])
|
35 |
+
|
36 |
|
37 |
def render_func(
|
38 |
obj_filename,
|
|
|
53 |
rgb: if set true, will convert result to rgb image/frame
|
54 |
'''
|
55 |
# load mesh
|
56 |
+
if obj_filename.endswith(".obj"): mesh = load_objs_as_meshes([obj_filename], device=device)
|
57 |
+
elif obj_filename.endswith(".glb"): mesh = load_glb_as_meshes(obj_filename, device)
|
58 |
+
else: raise f"only support obj or glb"
|
59 |
meshes = mesh.extend(n_views)
|
60 |
|
61 |
if azim is None:
|