Spaces:
Running
on
Zero
Running
on
Zero
xinjie.wang
commited on
Commit
·
8dc4043
1
Parent(s):
4091e8b
update
Browse files
common.py
CHANGED
@@ -495,13 +495,16 @@ def extract_3d_representations_v2(
|
|
495 |
enable_delight: bool,
|
496 |
req: gr.Request,
|
497 |
):
|
|
|
498 |
output_root = TMP_DIR
|
499 |
user_dir = os.path.join(output_root, str(req.session_hash))
|
500 |
gs_model, mesh_model = unpack_state(state, device="cpu")
|
|
|
501 |
|
502 |
filename = "sample"
|
503 |
gs_path = os.path.join(user_dir, f"{filename}_gs.ply")
|
504 |
gs_model.save_ply(gs_path)
|
|
|
505 |
|
506 |
# Rotate mesh and GS by 90 degrees around Z-axis.
|
507 |
rot_matrix = [[0, 0, -1], [0, 1, 0], [1, 0, 0]]
|
@@ -512,13 +515,16 @@ def extract_3d_representations_v2(
|
|
512 |
gs_rot = np.array(gs_add_rot) @ np.array(rot_matrix)
|
513 |
pose = GaussianOperator.trans_to_quatpose(gs_rot)
|
514 |
aligned_gs_path = gs_path.replace(".ply", "_aligned.ply")
|
|
|
515 |
GaussianOperator.resave_ply(
|
516 |
in_ply=gs_path,
|
517 |
out_ply=aligned_gs_path,
|
518 |
instance_pose=pose,
|
519 |
)
|
|
|
520 |
color_path = os.path.join(user_dir, "color.png")
|
521 |
render_gs_api(aligned_gs_path, color_path)
|
|
|
522 |
|
523 |
mesh = trimesh.Trimesh(
|
524 |
vertices=mesh_model.vertices.cpu().numpy(),
|
@@ -529,7 +535,7 @@ def extract_3d_representations_v2(
|
|
529 |
|
530 |
mesh_obj_path = os.path.join(user_dir, f"{filename}.obj")
|
531 |
mesh.export(mesh_obj_path)
|
532 |
-
|
533 |
mesh = backproject_api(
|
534 |
delight_model=DELIGHT,
|
535 |
imagesr_model=IMAGESR_MODEL,
|
@@ -539,6 +545,7 @@ def extract_3d_representations_v2(
|
|
539 |
skip_fix_mesh=False,
|
540 |
delight=enable_delight,
|
541 |
)
|
|
|
542 |
|
543 |
mesh_glb_path = os.path.join(user_dir, f"{filename}.glb")
|
544 |
mesh.export(mesh_glb_path)
|
|
|
495 |
enable_delight: bool,
|
496 |
req: gr.Request,
|
497 |
):
|
498 |
+
print("debug1")
|
499 |
output_root = TMP_DIR
|
500 |
user_dir = os.path.join(output_root, str(req.session_hash))
|
501 |
gs_model, mesh_model = unpack_state(state, device="cpu")
|
502 |
+
print("debug2")
|
503 |
|
504 |
filename = "sample"
|
505 |
gs_path = os.path.join(user_dir, f"{filename}_gs.ply")
|
506 |
gs_model.save_ply(gs_path)
|
507 |
+
print("debug3")
|
508 |
|
509 |
# Rotate mesh and GS by 90 degrees around Z-axis.
|
510 |
rot_matrix = [[0, 0, -1], [0, 1, 0], [1, 0, 0]]
|
|
|
515 |
gs_rot = np.array(gs_add_rot) @ np.array(rot_matrix)
|
516 |
pose = GaussianOperator.trans_to_quatpose(gs_rot)
|
517 |
aligned_gs_path = gs_path.replace(".ply", "_aligned.ply")
|
518 |
+
print("debug4")
|
519 |
GaussianOperator.resave_ply(
|
520 |
in_ply=gs_path,
|
521 |
out_ply=aligned_gs_path,
|
522 |
instance_pose=pose,
|
523 |
)
|
524 |
+
print("debug5")
|
525 |
color_path = os.path.join(user_dir, "color.png")
|
526 |
render_gs_api(aligned_gs_path, color_path)
|
527 |
+
print("debug6")
|
528 |
|
529 |
mesh = trimesh.Trimesh(
|
530 |
vertices=mesh_model.vertices.cpu().numpy(),
|
|
|
535 |
|
536 |
mesh_obj_path = os.path.join(user_dir, f"{filename}.obj")
|
537 |
mesh.export(mesh_obj_path)
|
538 |
+
print("debug7")
|
539 |
mesh = backproject_api(
|
540 |
delight_model=DELIGHT,
|
541 |
imagesr_model=IMAGESR_MODEL,
|
|
|
545 |
skip_fix_mesh=False,
|
546 |
delight=enable_delight,
|
547 |
)
|
548 |
+
print("debug8")
|
549 |
|
550 |
mesh_glb_path = os.path.join(user_dir, f"{filename}.glb")
|
551 |
mesh.export(mesh_glb_path)
|