import gradio as gr
import os
import glob
base_dir = os.path.dirname(__file__)
examples_dir = os.path.join(base_dir, 'examples')
with gr.Blocks() as iface:
gr.HTML("""
An application that generates 3D meshes from multiple 2D images.
Created by
Abolfazl Mohajeri
""")
with gr.Row():
with gr.Column():
output_mesh = gr.Model3D(label="3D Mesh", inputs=None, interactive=False)
gr.HTML("""
Examples
Click the render button below each example to see the output in the box above
""")
with gr.Row():
with gr.Column():
gr.HTML("""
Example 1
""")
gr.Gallery(label="Input Images",
columns=3,
object_fit="contain",
value=glob.glob(os.path.join(examples_dir, 'fox', 'input', '*')))
gr.Button("Render").click(lambda: os.path.join(examples_dir, 'fox', 'output', "mesh.glb"), inputs=None, outputs=output_mesh)
with gr.Column():
gr.HTML("""
Example 2
""")
gr.Gallery(label="Input Images",
columns=3,
object_fit="contain",
value=glob.glob(os.path.join(examples_dir, 'buddha', 'input', '*')))
gr.Button("Render").click(lambda : os.path.join(examples_dir, 'buddha', 'output', "mesh.glb"), inputs=None, outputs=output_mesh)
with gr.Column():
gr.HTML("""
Example 3
""")
gr.Gallery(label="Input Images",
columns=3,
object_fit="contain",
value=glob.glob(os.path.join(examples_dir, 'stone', 'input', '*')))
gr.Button("Render").click(lambda: os.path.join(examples_dir, 'stone', 'output', "mesh.glb"), inputs=None,outputs=output_mesh)
gr.HTML("""
""")
iface.launch(allowed_paths=["static"])