Update code for .ply file downloading
Browse files
app.py
CHANGED
|
@@ -14,7 +14,7 @@ import spaces
|
|
| 14 |
|
| 15 |
from pi3.utils.geometry import se3_inverse, homogenize_points, depth_edge
|
| 16 |
from pi3.models.pi3 import Pi3
|
| 17 |
-
from pi3.utils.basic import load_images_as_tensor
|
| 18 |
|
| 19 |
import trimesh
|
| 20 |
import matplotlib
|
|
@@ -143,7 +143,7 @@ def predictions_to_glb(
|
|
| 143 |
scene_3d.apply_transform(align_rotation)
|
| 144 |
|
| 145 |
print("GLB Scene built")
|
| 146 |
-
return scene_3d,
|
| 147 |
|
| 148 |
def integrate_camera_into_scene(scene: trimesh.Scene, transform: np.ndarray, face_colors: tuple, scene_scale: float):
|
| 149 |
"""
|
|
@@ -455,7 +455,7 @@ def gradio_demo(
|
|
| 455 |
)
|
| 456 |
|
| 457 |
# Convert predictions to GLB
|
| 458 |
-
glbscene,
|
| 459 |
predictions,
|
| 460 |
conf_thres=conf_thres,
|
| 461 |
filter_by_frames=frame_filter,
|
|
@@ -465,7 +465,7 @@ def gradio_demo(
|
|
| 465 |
|
| 466 |
# we save a .ply file too
|
| 467 |
plyfile = glbfile.replace('.glb', '.ply')
|
| 468 |
-
|
| 469 |
|
| 470 |
# Cleanup
|
| 471 |
del predictions
|
|
@@ -795,7 +795,7 @@ if __name__ == '__main__':
|
|
| 795 |
reconstruction_output = gr.Model3D(height=480, zoom_speed=0.5, pan_speed=0.5, label="3D Output")
|
| 796 |
|
| 797 |
# optional to download .ply file
|
| 798 |
-
download_ply_output = gr.File(label="Download .ply Result", interactive=False)
|
| 799 |
|
| 800 |
with gr.Row():
|
| 801 |
submit_btn = gr.Button("Reconstruct", scale=3, variant="primary")
|
|
|
|
| 14 |
|
| 15 |
from pi3.utils.geometry import se3_inverse, homogenize_points, depth_edge
|
| 16 |
from pi3.models.pi3 import Pi3
|
| 17 |
+
from pi3.utils.basic import load_images_as_tensor, write_ply
|
| 18 |
|
| 19 |
import trimesh
|
| 20 |
import matplotlib
|
|
|
|
| 143 |
scene_3d.apply_transform(align_rotation)
|
| 144 |
|
| 145 |
print("GLB Scene built")
|
| 146 |
+
return scene_3d, [vertices_3d, colors_rgb]
|
| 147 |
|
| 148 |
def integrate_camera_into_scene(scene: trimesh.Scene, transform: np.ndarray, face_colors: tuple, scene_scale: float):
|
| 149 |
"""
|
|
|
|
| 455 |
)
|
| 456 |
|
| 457 |
# Convert predictions to GLB
|
| 458 |
+
glbscene, pcd = predictions_to_glb(
|
| 459 |
predictions,
|
| 460 |
conf_thres=conf_thres,
|
| 461 |
filter_by_frames=frame_filter,
|
|
|
|
| 465 |
|
| 466 |
# we save a .ply file too
|
| 467 |
plyfile = glbfile.replace('.glb', '.ply')
|
| 468 |
+
write_ply(pcd[0], pcd[1]/255, path=plyfile)
|
| 469 |
|
| 470 |
# Cleanup
|
| 471 |
del predictions
|
|
|
|
| 795 |
reconstruction_output = gr.Model3D(height=480, zoom_speed=0.5, pan_speed=0.5, label="3D Output")
|
| 796 |
|
| 797 |
# optional to download .ply file
|
| 798 |
+
download_ply_output = gr.File(height=100, label="Download .ply Result", interactive=False)
|
| 799 |
|
| 800 |
with gr.Row():
|
| 801 |
submit_btn = gr.Button("Reconstruct", scale=3, variant="primary")
|