Spaces:
Sleeping
Sleeping
| 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() | |