Commit ·
ae4da09
1
Parent(s): eecf206
still initial commit
Browse files
app.py
CHANGED
|
@@ -74,27 +74,25 @@ def process_demo_stream(frame: np.ndarray) -> np.ndarray:
|
|
| 74 |
return np.hstack([raw_labeled, processed])
|
| 75 |
|
| 76 |
|
| 77 |
-
# ──
|
| 78 |
-
# Use elem_classes on gr.Group + gr.Column, not elem_id CSS targeting
|
| 79 |
-
# Use height= directly on WebRTC() — the component accepts it natively
|
| 80 |
css = """
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
max-height: 480px !important;
|
| 84 |
-
overflow: hidden !important;
|
| 85 |
-
}
|
| 86 |
-
.webrtc-col {
|
| 87 |
-
display: flex !important;
|
| 88 |
-
justify-content: center !important;
|
| 89 |
-
align-items: flex-start !important;
|
| 90 |
-
}
|
| 91 |
"""
|
| 92 |
|
| 93 |
# ── UI ───────────────────────────────────────────────────────────────────────
|
| 94 |
with gr.Blocks(title="Minecraft Spatial Voxel Filter", css=css) as demo:
|
| 95 |
|
| 96 |
-
gr.
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
mode_dropdown = gr.Dropdown(
|
| 100 |
choices=["Minecraft Filter", "Streaming Demo"],
|
|
@@ -103,10 +101,11 @@ with gr.Blocks(title="Minecraft Spatial Voxel Filter", css=css) as demo:
|
|
| 103 |
interactive=True,
|
| 104 |
)
|
| 105 |
|
| 106 |
-
|
|
|
|
| 107 |
|
| 108 |
-
#
|
| 109 |
-
with gr.Column(
|
| 110 |
gr.Markdown("### 🎛️ Environmental Filters")
|
| 111 |
prompt_input = gr.Textbox(
|
| 112 |
value="vanilla minecraft voxel landscape, 3d blocky style, retro game cube aesthetic",
|
|
@@ -120,31 +119,30 @@ with gr.Blocks(title="Minecraft Spatial Voxel Filter", css=css) as demo:
|
|
| 120 |
status_color = "🟢" if voxel_backend is not None else "🔴"
|
| 121 |
status_text = "Connected" if voxel_backend is not None else "Offline"
|
| 122 |
gr.Markdown(f"**Modal Backend:** {status_color} `{status_text}`")
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
)
|
| 148 |
|
| 149 |
# ── Mode Switch ──────────────────────────────────────────────────────────
|
| 150 |
def switch_layout(selected_mode):
|
|
|
|
| 74 |
return np.hstack([raw_labeled, processed])
|
| 75 |
|
| 76 |
|
| 77 |
+
# ── CSS: exact pattern from official FastRTC docs ──────────────────────────
|
|
|
|
|
|
|
| 78 |
css = """
|
| 79 |
+
#webrtc-single { max-width: 600px !important; max-height: 600px !important; }
|
| 80 |
+
#webrtc-demo { max-width: 900px !important; max-height: 600px !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
"""
|
| 82 |
|
| 83 |
# ── UI ───────────────────────────────────────────────────────────────────────
|
| 84 |
with gr.Blocks(title="Minecraft Spatial Voxel Filter", css=css) as demo:
|
| 85 |
|
| 86 |
+
gr.HTML("""
|
| 87 |
+
<div style='display: flex; align-items: center; justify-content: center; gap: 16px; padding: 12px 0'>
|
| 88 |
+
<div>
|
| 89 |
+
<h1 style='margin: 0'>⛏️ MINECRAFT SPATIAL VOXEL FILTER ⛏️</h1>
|
| 90 |
+
<p style='margin: 4px 0 0 0; text-align: center'>
|
| 91 |
+
Transform your environment into a real-time blocky landscape
|
| 92 |
+
</p>
|
| 93 |
+
</div>
|
| 94 |
+
</div>
|
| 95 |
+
""")
|
| 96 |
|
| 97 |
mode_dropdown = gr.Dropdown(
|
| 98 |
choices=["Minecraft Filter", "Streaming Demo"],
|
|
|
|
| 101 |
interactive=True,
|
| 102 |
)
|
| 103 |
|
| 104 |
+
# ── Mode 1: Minecraft Filter ───────────────────────────────────────────
|
| 105 |
+
with gr.Row(visible=True) as minecraft_layout:
|
| 106 |
|
| 107 |
+
# Left: controls
|
| 108 |
+
with gr.Column():
|
| 109 |
gr.Markdown("### 🎛️ Environmental Filters")
|
| 110 |
prompt_input = gr.Textbox(
|
| 111 |
value="vanilla minecraft voxel landscape, 3d blocky style, retro game cube aesthetic",
|
|
|
|
| 119 |
status_color = "🟢" if voxel_backend is not None else "🔴"
|
| 120 |
status_text = "Connected" if voxel_backend is not None else "Offline"
|
| 121 |
gr.Markdown(f"**Modal Backend:** {status_color} `{status_text}`")
|
| 122 |
+
|
| 123 |
+
# Right: video — elem_id + CSS, exactly like the docs example
|
| 124 |
+
with gr.Column():
|
| 125 |
+
gr.Markdown("### 📺 Spatial Render Pipeline")
|
| 126 |
+
webrtc_single = WebRTC(
|
| 127 |
+
label="Live Voxel Viewport",
|
| 128 |
+
modality="video",
|
| 129 |
+
mode="send-receive",
|
| 130 |
+
elem_id="webrtc-single", # ← docs pattern
|
| 131 |
+
rtc_configuration=get_cloudflare_turn_credentials,
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
# ── Mode 2: Streaming Demo ─────────────────────────────────────────────
|
| 135 |
+
with gr.Row(visible=False) as demo_layout:
|
| 136 |
+
|
| 137 |
+
with gr.Column():
|
| 138 |
+
gr.Markdown("### 📺 Dual-Feed · _Left: Raw · Right: Minecraft_")
|
| 139 |
+
webrtc_demo = WebRTC(
|
| 140 |
+
label="Live Side-by-Side Feed",
|
| 141 |
+
modality="video",
|
| 142 |
+
mode="send-receive",
|
| 143 |
+
elem_id="webrtc-demo", # ← docs pattern
|
| 144 |
+
rtc_configuration=get_cloudflare_turn_credentials,
|
| 145 |
+
)
|
|
|
|
| 146 |
|
| 147 |
# ── Mode Switch ──────────────────────────────────────────────────────────
|
| 148 |
def switch_layout(selected_mode):
|