Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,60 +1,37 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
return
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
|
| 11 |
def ui():
|
| 12 |
-
with gr.Blocks(title="Sparse Multi
|
| 13 |
-
gr.Markdown(
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
)
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
with gr.
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
tris = gr.Slider(0, 500_000, value=150_000, step=10_000, label="Target triangles (0 = keep)")
|
| 34 |
-
|
| 35 |
-
run = gr.Button("▶ Reconstruct 3D")
|
| 36 |
-
with gr.Column(scale=1):
|
| 37 |
-
preview = gr.Model3D(label="Mesh preview", visible=False)
|
| 38 |
-
files_out = gr.Files(label="Downloads (GLB/OBJ/PLY)")
|
| 39 |
-
logs = gr.Markdown("Logs will appear here after running…")
|
| 40 |
-
|
| 41 |
-
run.click(
|
| 42 |
-
run_pipeline,
|
| 43 |
-
[gallery, max_px, match_mode, use_gpu_sift, voxel, depth, tris],
|
| 44 |
-
[preview, files_out, logs, preview],
|
| 45 |
-
queue=True,
|
| 46 |
-
)
|
| 47 |
-
|
| 48 |
-
gr.Markdown(
|
| 49 |
-
"""
|
| 50 |
-
### Notes & Scaling
|
| 51 |
-
- Results are in **arbitrary units** (SfM scale). For metric scale, align the mesh in GIS/CAD using known distances.
|
| 52 |
-
- Outdoor scenes with repetitive textures (glass, trees) can be challenging—add a few more oblique views if possible.
|
| 53 |
-
"""
|
| 54 |
-
)
|
| 55 |
-
|
| 56 |
-
return demo
|
| 57 |
-
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
| 60 |
-
ui().launch()
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from PIL import Image
|
| 3 |
+
|
| 4 |
+
def run_pipeline(gallery, max_px, match_mode, use_gpu_sift, voxel, depth, tris):
|
| 5 |
+
try:
|
| 6 |
+
logs = []
|
| 7 |
+
# TODO: your pipeline here
|
| 8 |
+
# return (preview_path, [file_paths...], "\n".join(logs[-6:]), gr.update(visible=True))
|
| 9 |
+
return None, [], "Ready.", gr.update(visible=False)
|
| 10 |
+
except Exception as e:
|
| 11 |
+
return None, None, f"[ERROR]\n{e}", gr.update(visible=False)
|
| 12 |
|
| 13 |
def ui():
|
| 14 |
+
with gr.Blocks(title="Sparse Multi-View 3D (Urban Planning)") as demo:
|
| 15 |
+
gr.Markdown("# Sparse Multi-View 3D for Urban Planning")
|
| 16 |
+
with gr.Row():
|
| 17 |
+
with gr.Column(scale=2):
|
| 18 |
+
imgs = gr.UploadButton("Upload images (JPG/PNG)", file_types=["image"], file_count="multiple")
|
| 19 |
+
gallery = gr.Gallery(label="Selected", columns=6, height=160)
|
| 20 |
+
imgs.upload(lambda files: [(f.name, Image.open(f).convert('RGB')) for f in files], imgs, gallery)
|
| 21 |
+
max_px = gr.Slider(1024, 4096, value=2400, step=64, label="Max image size (px)")
|
| 22 |
+
match_mode = gr.Radio(["exhaustive", "sequential", "spatial"], value="sequential", label="Matching mode")
|
| 23 |
+
use_gpu_sift = gr.Checkbox(True, label="Use GPU for SIFT (if available)")
|
| 24 |
+
voxel = gr.Slider(0.0, 0.05, value=0.01, step=0.005, label="Voxel downsample")
|
| 25 |
+
depth = gr.Slider(6, 12, value=9, step=1, label="Poisson depth")
|
| 26 |
+
tris = gr.Slider(0, 500_000, value=150_000, step=10_000, label="Target triangles")
|
| 27 |
+
run = gr.Button("▶ Reconstruct 3D")
|
| 28 |
+
with gr.Column(scale=1):
|
| 29 |
+
preview = gr.Model3D(label="Mesh preview", visible=False)
|
| 30 |
+
files_out = gr.Files(label="Downloads (GLB/OBJ/PLY)")
|
| 31 |
+
logs = gr.Markdown("Logs will appear here after running…")
|
| 32 |
+
run.click(run_pipeline, [gallery, max_px, match_mode, use_gpu_sift, voxel, depth, tris],
|
| 33 |
+
[preview, files_out, logs, preview], queue=True)
|
| 34 |
+
return demo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
if __name__ == "__main__":
|
| 37 |
+
ui().launch()
|