File size: 1,657 Bytes
ddefedb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import gradio as gr
import subprocess


def run(input_ply):
    subprocess.run(
        "python3.10 convert.py big --force-cuda-rast --test_path " + input_ply,
        shell=True,
    )
    return input_ply.replace(".ply", ".glb")


def main():
    title = """Splat to Mesh"""

    description = """
    Converts Gaussian Splat (.ply) to Mesh (.glb) using [LGM](https://github.com/3DTopia/LGM).
    
    For faster inference without waiting in a queue, you may duplicate the space and upgrade to a GPU in the settings.
    """

    css = """
    #duplicate-button {
        margin: auto;
        color: white;
        background: #1565c0;
        border-radius: 100vh;
    }
    """

    with gr.Blocks(title=title, css=css) as demo:
        gr.DuplicateButton(
            value="Duplicate Space for private use", elem_id="duplicate-button"
        )

        with gr.Row():
            with gr.Column():
                gr.Markdown("# " + title + "\n" + description)

        with gr.Row(variant="panel"):
            with gr.Column():
                input_ply = gr.Model3D(label="Input Splat")
                button_gen = gr.Button("Convert")

            with gr.Column():
                output_glb = gr.Model3D(label="Output GLB")

            button_gen.click(run, inputs=[input_ply], outputs=[output_glb])

        gr.Examples(
            ["data_test/catstatue.ply"],
            inputs=[input_ply],
            outputs=[output_glb],
            fn=lambda x: run(x),
            cache_examples=True,
            label="Examples",
        )

    demo.queue().launch(server_name="0.0.0.0", server_port=7860)


if __name__ == "__main__":
    main()