Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from content import TAB_ABOUT
|
| 3 |
from arch_content import TAB_ARCH
|
| 4 |
from bench_content import TAB_BENCH
|
| 5 |
from usage_content import TAB_USAGE
|
|
|
|
| 6 |
|
| 7 |
CSS = """
|
| 8 |
#container{max-width:1100px;margin:0 auto}
|
|
@@ -13,11 +15,30 @@ CSS = """
|
|
| 13 |
.stat{text-align:center}
|
| 14 |
.stat-value{font-size:2em;font-weight:700;color:#4f46e5}
|
| 15 |
.stat-label{font-size:.85em;color:#6b7280}
|
| 16 |
-
.video-wrap{position:relative;padding-bottom:56.25%;height:0;overflow:hidden;border-radius:12px}
|
| 17 |
-
.video-wrap iframe{position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:12px}
|
| 18 |
footer{display:none!important}
|
| 19 |
"""
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
with gr.Blocks(title="LingBot-Map Explorer", css=CSS) as demo:
|
| 22 |
with gr.Column(elem_id="container"):
|
| 23 |
gr.Markdown(
|
|
@@ -33,6 +54,21 @@ with gr.Blocks(title="LingBot-Map Explorer", css=CSS) as demo:
|
|
| 33 |
'</div>'
|
| 34 |
)
|
| 35 |
with gr.Tabs():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
with gr.Tab("๐ About"):
|
| 37 |
gr.Markdown(TAB_ABOUT)
|
| 38 |
with gr.Tab("๐ง Architecture"):
|
|
@@ -42,4 +78,10 @@ with gr.Blocks(title="LingBot-Map Explorer", css=CSS) as demo:
|
|
| 42 |
with gr.Tab("๐ Usage"):
|
| 43 |
gr.Markdown(TAB_USAGE)
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from gradio_client import Client, file
|
| 3 |
from content import TAB_ABOUT
|
| 4 |
from arch_content import TAB_ARCH
|
| 5 |
from bench_content import TAB_BENCH
|
| 6 |
from usage_content import TAB_USAGE
|
| 7 |
+
from infer_content import INFERENCE_TAB
|
| 8 |
|
| 9 |
CSS = """
|
| 10 |
#container{max-width:1100px;margin:0 auto}
|
|
|
|
| 15 |
.stat{text-align:center}
|
| 16 |
.stat-value{font-size:2em;font-weight:700;color:#4f46e5}
|
| 17 |
.stat-label{font-size:.85em;color:#6b7280}
|
|
|
|
|
|
|
| 18 |
footer{display:none!important}
|
| 19 |
"""
|
| 20 |
|
| 21 |
+
def run_inference(video_path, fps, max_frames, num_scale, keyframe_int, conf_pct):
|
| 22 |
+
if not video_path:
|
| 23 |
+
return None, None, "โ Please upload a video first."
|
| 24 |
+
try:
|
| 25 |
+
client = Client("dennny123/lingbot-3d")
|
| 26 |
+
result = client.predict(
|
| 27 |
+
video_file=file(video_path),
|
| 28 |
+
fps=int(fps),
|
| 29 |
+
max_frames=int(max_frames),
|
| 30 |
+
num_scale_frames=int(num_scale),
|
| 31 |
+
keyframe_interval=int(keyframe_int),
|
| 32 |
+
conf_percentile=float(conf_pct),
|
| 33 |
+
api_name="/reconstruct_scene"
|
| 34 |
+
)
|
| 35 |
+
glb_path = result[1]
|
| 36 |
+
img_path = result[2]
|
| 37 |
+
status = result[5]
|
| 38 |
+
return glb_path, img_path, f"โ
{status}"
|
| 39 |
+
except Exception as e:
|
| 40 |
+
return None, None, f"โ Error: {str(e)}"
|
| 41 |
+
|
| 42 |
with gr.Blocks(title="LingBot-Map Explorer", css=CSS) as demo:
|
| 43 |
with gr.Column(elem_id="container"):
|
| 44 |
gr.Markdown(
|
|
|
|
| 54 |
'</div>'
|
| 55 |
)
|
| 56 |
with gr.Tabs():
|
| 57 |
+
with gr.Tab("๐ฎ Run Inference"):
|
| 58 |
+
gr.Markdown(INFERENCE_TAB)
|
| 59 |
+
vid = gr.Video(label="Input video", sources=["upload"])
|
| 60 |
+
with gr.Row():
|
| 61 |
+
fps = gr.Slider(1, 12, value=8, step=1, label="Sampling FPS")
|
| 62 |
+
max_fr = gr.Slider(2, 24, value=24, step=1, label="Max frames")
|
| 63 |
+
with gr.Row():
|
| 64 |
+
num_sc = gr.Slider(1, 8, value=4, step=1, label="Scale frames")
|
| 65 |
+
kf_int = gr.Slider(1, 8, value=2, step=1, label="Keyframe interval")
|
| 66 |
+
conf = gr.Slider(0, 90, value=50, step=5, label="Confidence percentile")
|
| 67 |
+
btn = gr.Button("Build 3D Scene", variant="primary")
|
| 68 |
+
status = gr.Markdown()
|
| 69 |
+
with gr.Row():
|
| 70 |
+
glb_out = gr.Model3D(label="3D Result", display_mode="point_cloud")
|
| 71 |
+
img_out = gr.Image(label="Frame preview")
|
| 72 |
with gr.Tab("๐ About"):
|
| 73 |
gr.Markdown(TAB_ABOUT)
|
| 74 |
with gr.Tab("๐ง Architecture"):
|
|
|
|
| 78 |
with gr.Tab("๐ Usage"):
|
| 79 |
gr.Markdown(TAB_USAGE)
|
| 80 |
|
| 81 |
+
btn.click(
|
| 82 |
+
run_inference,
|
| 83 |
+
[vid, fps, max_fr, num_sc, kf_int, conf],
|
| 84 |
+
[glb_out, img_out, status]
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
demo.launch()
|