Update app.py
Browse files
app.py
CHANGED
@@ -27,6 +27,7 @@ from src.misc.image_io import save_interpolated_video
|
|
27 |
from src.model.model.anysplat import AnySplat
|
28 |
from src.model.ply_export import export_ply
|
29 |
from src.utils.image import process_image
|
|
|
30 |
|
31 |
os.environ["ANYSPLAT_PROCESSED"] = f"{os.getcwd()}/proprocess_results"
|
32 |
|
@@ -75,9 +76,22 @@ def get_reconstructed_scene(outdir, model, device):
|
|
75 |
save_sh_dc_only=True,
|
76 |
)
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
# Clean up
|
83 |
torch.cuda.empty_cache()
|
|
|
27 |
from src.model.model.anysplat import AnySplat
|
28 |
from src.model.ply_export import export_ply
|
29 |
from src.utils.image import process_image
|
30 |
+
import open3d as o3d
|
31 |
|
32 |
os.environ["ANYSPLAT_PROCESSED"] = f"{os.getcwd()}/proprocess_results"
|
33 |
|
|
|
76 |
save_sh_dc_only=True,
|
77 |
)
|
78 |
|
79 |
+
import trimesh
|
80 |
+
import numpy as np
|
81 |
+
|
82 |
+
# 1. Load PLY and preserve attributes
|
83 |
+
mesh = trimesh.load(plyfile, process=False)
|
84 |
+
|
85 |
+
# 2. Check or assign vertex colors
|
86 |
+
if mesh.visual.vertex_colors is None or mesh.visual.vertex_colors.shape[1] < 4:
|
87 |
+
# Example: assume mesh.metadata['vertex_color'] holds (N×3) array
|
88 |
+
rgb = np.array(mesh.metadata['vertex_color'], dtype=np.uint8)
|
89 |
+
alpha = np.full((rgb.shape[0], 1), 255, dtype=np.uint8)
|
90 |
+
mesh.visual.vertex_colors = np.concatenate([rgb, alpha], axis=1)
|
91 |
+
|
92 |
+
# 3. Export GLB
|
93 |
+
mesh.export(glbfile, file_type='glb')
|
94 |
+
print("Export complete: scene_colored.glb")
|
95 |
|
96 |
# Clean up
|
97 |
torch.cuda.empty_cache()
|