Spaces:
Runtime error
Runtime error
Created app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def run(input_ply):
|
| 6 |
+
subprocess.run(
|
| 7 |
+
"python3.10 convert.py big --force-cuda-rast --test_path " + input_ply,
|
| 8 |
+
shell=True,
|
| 9 |
+
)
|
| 10 |
+
return input_ply.replace(".ply", ".glb")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def main():
|
| 14 |
+
title = """Splat to Mesh"""
|
| 15 |
+
|
| 16 |
+
description = """
|
| 17 |
+
Converts Gaussian Splat (.ply) to Mesh (.glb) using [LGM](https://github.com/3DTopia/LGM).
|
| 18 |
+
|
| 19 |
+
For faster inference without waiting in a queue, you may duplicate the space and upgrade to a GPU in the settings.
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
css = """
|
| 23 |
+
#duplicate-button {
|
| 24 |
+
margin: auto;
|
| 25 |
+
color: white;
|
| 26 |
+
background: #1565c0;
|
| 27 |
+
border-radius: 100vh;
|
| 28 |
+
}
|
| 29 |
+
"""
|
| 30 |
+
|
| 31 |
+
with gr.Blocks(title=title, css=css) as demo:
|
| 32 |
+
gr.DuplicateButton(
|
| 33 |
+
value="Duplicate Space for private use", elem_id="duplicate-button"
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
with gr.Row():
|
| 37 |
+
with gr.Column():
|
| 38 |
+
gr.Markdown("# " + title + "\n" + description)
|
| 39 |
+
|
| 40 |
+
with gr.Row(variant="panel"):
|
| 41 |
+
with gr.Column():
|
| 42 |
+
input_ply = gr.Model3D(label="Input Splat")
|
| 43 |
+
button_gen = gr.Button("Convert")
|
| 44 |
+
|
| 45 |
+
with gr.Column():
|
| 46 |
+
output_glb = gr.Model3D(label="Output GLB")
|
| 47 |
+
|
| 48 |
+
button_gen.click(run, inputs=[input_ply], outputs=[output_glb])
|
| 49 |
+
|
| 50 |
+
gr.Examples(
|
| 51 |
+
["data_test/catstatue.ply"],
|
| 52 |
+
inputs=[input_ply],
|
| 53 |
+
outputs=[output_glb],
|
| 54 |
+
fn=lambda x: run(x),
|
| 55 |
+
cache_examples=True,
|
| 56 |
+
label="Examples",
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
demo.queue().launch(server_name="0.0.0.0", server_port=7860)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
if __name__ == "__main__":
|
| 63 |
+
main()
|