Anshuman Singh commited on
Commit ·
aa41bac
1
Parent(s): 20ad86b
Fix GIF animation (base64 embed for Gradio 5.x); add summary.md to gitignore
Browse files- .gitignore +1 -0
- app.py +11 -3
.gitignore
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
context.md
|
|
|
|
| 2 |
__pycache__/
|
| 3 |
*.pyc
|
| 4 |
*.pyo
|
|
|
|
| 1 |
context.md
|
| 2 |
+
summary.md
|
| 3 |
__pycache__/
|
| 4 |
*.pyc
|
| 5 |
*.pyo
|
app.py
CHANGED
|
@@ -61,8 +61,16 @@ def run_planning(scenario, r0, r1, r2, r3, animate):
|
|
| 61 |
|
| 62 |
if animate and result.success:
|
| 63 |
gif = render_animation(grid, result, fps=3)
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
|
| 68 |
def update_scenario_ui(scenario):
|
|
@@ -133,7 +141,7 @@ the **highest-priority** rules and minimally violates the rest.
|
|
| 133 |
|
| 134 |
with gr.Column(scale=2):
|
| 135 |
grid_img = gr.Image(label="Planned Path", type="pil", height=420)
|
| 136 |
-
anim_img = gr.
|
| 137 |
result_md = gr.HTML(label="Spec Satisfaction")
|
| 138 |
|
| 139 |
scenario_dd.change(
|
|
|
|
| 61 |
|
| 62 |
if animate and result.success:
|
| 63 |
gif = render_animation(grid, result, fps=3)
|
| 64 |
+
# Embed as base64 so Gradio 5.x HTML component plays it natively
|
| 65 |
+
import base64
|
| 66 |
+
with open(gif, "rb") as f:
|
| 67 |
+
b64 = base64.b64encode(f.read()).decode()
|
| 68 |
+
gif_html = (
|
| 69 |
+
f"<img src='data:image/gif;base64,{b64}' "
|
| 70 |
+
f"style='max-width:100%;border-radius:8px'/>"
|
| 71 |
+
)
|
| 72 |
+
return static, gif_html, html
|
| 73 |
+
return static, "", html
|
| 74 |
|
| 75 |
|
| 76 |
def update_scenario_ui(scenario):
|
|
|
|
| 141 |
|
| 142 |
with gr.Column(scale=2):
|
| 143 |
grid_img = gr.Image(label="Planned Path", type="pil", height=420)
|
| 144 |
+
anim_img = gr.HTML(label="Animation (GIF)")
|
| 145 |
result_md = gr.HTML(label="Spec Satisfaction")
|
| 146 |
|
| 147 |
scenario_dd.change(
|