File size: 2,074 Bytes
f8d6272
 
 
 
 
 
 
 
 
 
 
6cd3957
 
f8d6272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6cd3957
 
f8d6272
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
import gradio as gr
from PIL import Image

def run_pipeline(gallery, max_px, match_mode, use_gpu_sift, voxel, depth, tris):
    try:
        logs = []
        # TODO: your pipeline here
        # return (preview_path, [file_paths...], "\n".join(logs[-6:]), gr.update(visible=True))
        return None, [], "Ready.", gr.update(visible=False)
    except Exception as e:
        return None, None, f"[ERROR]\n{e}", gr.update(visible=False)

def ui():
    with gr.Blocks(title="Sparse Multi-View 3D (Urban Planning)") as demo:
        gr.Markdown("# Sparse Multi-View 3D for Urban Planning")
        with gr.Row():
            with gr.Column(scale=2):
                imgs = gr.UploadButton("Upload images (JPG/PNG)", file_types=["image"], file_count="multiple")
                gallery = gr.Gallery(label="Selected", columns=6, height=160)
                imgs.upload(lambda files: [(f.name, Image.open(f).convert('RGB')) for f in files], imgs, gallery)
                max_px = gr.Slider(1024, 4096, value=2400, step=64, label="Max image size (px)")
                match_mode = gr.Radio(["exhaustive", "sequential", "spatial"], value="sequential", label="Matching mode")
                use_gpu_sift = gr.Checkbox(True, label="Use GPU for SIFT (if available)")
                voxel = gr.Slider(0.0, 0.05, value=0.01, step=0.005, label="Voxel downsample")
                depth = gr.Slider(6, 12, value=9, step=1, label="Poisson depth")
                tris = gr.Slider(0, 500_000, value=150_000, step=10_000, label="Target triangles")
                run = gr.Button("▶ Reconstruct 3D")
            with gr.Column(scale=1):
                preview = gr.Model3D(label="Mesh preview", visible=False)
                files_out = gr.Files(label="Downloads (GLB/OBJ/PLY)")
                logs = gr.Markdown("Logs will appear here after running…")
        run.click(run_pipeline, [gallery, max_px, match_mode, use_gpu_sift, voxel, depth, tris],
                  [preview, files_out, logs, preview], queue=True)
    return demo

if __name__ == "__main__":
    ui().launch()