Spaces:
Running
Running
Simon Clematide commited on
Commit ยท
b3fd1bf
1
Parent(s): add3b9b
Activate Step-by-Step Trace tab when clicking Generate Trace
Browse files
app.py
CHANGED
|
@@ -274,7 +274,7 @@ def build_visual_grammar_html():
|
|
| 274 |
for title, label, description in samples) + '</div>'
|
| 275 |
|
| 276 |
|
| 277 |
-
with gr.Blocks(title="Autodiff Mermaid Visualizer") as demo:
|
| 278 |
gr.Markdown("# ๐งฎ Autodiff Mermaid Visualizer")
|
| 279 |
gr.Markdown("Type any mathematical expression and supply numerical values to visualize the computational graph and derivative calculus.")
|
| 280 |
|
|
@@ -309,8 +309,8 @@ with gr.Blocks(title="Autodiff Mermaid Visualizer") as demo:
|
|
| 309 |
btn_diagram = gr.Button("Generate Diagram", variant="primary")
|
| 310 |
btn_trace = gr.Button("Generate Trace", variant="primary")
|
| 311 |
|
| 312 |
-
with gr.Tabs():
|
| 313 |
-
with gr.TabItem("๐ Visual Diagram"):
|
| 314 |
diagram_output = gr.HTML(label="Diagram")
|
| 315 |
|
| 316 |
with gr.Accordion("๐ฅ Download & Export (On-Demand)", open=True):
|
|
@@ -327,12 +327,12 @@ with gr.Blocks(title="Autodiff Mermaid Visualizer") as demo:
|
|
| 327 |
with gr.Accordion("๐ก Visual Grammar & Diagram Guide", open=True):
|
| 328 |
gr.HTML(build_visual_grammar_html())
|
| 329 |
|
| 330 |
-
with gr.TabItem("๐ Step-by-Step Trace"):
|
| 331 |
-
trace_output = gr.HTML(label="Step-by-step trace"
|
| 332 |
|
| 333 |
-
with gr.TabItem("๐ป Mermaid Code"):
|
| 334 |
code_output = gr.Code(label="Mermaid Syntax", language="markdown")
|
| 335 |
-
with gr.TabItem("๐ Online Help"):
|
| 336 |
gr.Markdown(
|
| 337 |
VISUAL_LANGUAGE + r"""
|
| 338 |
|
|
@@ -491,18 +491,18 @@ All supplied variables are differentiable real inputs. Thus examples may also sh
|
|
| 491 |
)
|
| 492 |
|
| 493 |
btn_diagram.click(
|
| 494 |
-
generate_diagram,
|
| 495 |
inputs=[expr_input, vals_input, mode_input, notation_input],
|
| 496 |
-
outputs=[diagram_output, code_output]
|
| 497 |
).then(
|
| 498 |
reset_downloads,
|
| 499 |
outputs=[download_pdf, download_png, download_svg]
|
| 500 |
)
|
| 501 |
|
| 502 |
btn_trace.click(
|
| 503 |
-
generate_trace,
|
| 504 |
inputs=[expr_input, vals_input, mode_input, notation_input],
|
| 505 |
-
outputs=[trace_output]
|
| 506 |
)
|
| 507 |
|
| 508 |
def load_initial_outputs(expr, vals, mode, notation):
|
|
|
|
| 274 |
for title, label, description in samples) + '</div>'
|
| 275 |
|
| 276 |
|
| 277 |
+
with gr.Blocks(title="Autodiff Mermaid Visualizer", head=TRACE_VIEW_SCRIPT) as demo:
|
| 278 |
gr.Markdown("# ๐งฎ Autodiff Mermaid Visualizer")
|
| 279 |
gr.Markdown("Type any mathematical expression and supply numerical values to visualize the computational graph and derivative calculus.")
|
| 280 |
|
|
|
|
| 309 |
btn_diagram = gr.Button("Generate Diagram", variant="primary")
|
| 310 |
btn_trace = gr.Button("Generate Trace", variant="primary")
|
| 311 |
|
| 312 |
+
with gr.Tabs(selected="tab_diagram") as main_tabs:
|
| 313 |
+
with gr.TabItem("๐ Visual Diagram", id="tab_diagram"):
|
| 314 |
diagram_output = gr.HTML(label="Diagram")
|
| 315 |
|
| 316 |
with gr.Accordion("๐ฅ Download & Export (On-Demand)", open=True):
|
|
|
|
| 327 |
with gr.Accordion("๐ก Visual Grammar & Diagram Guide", open=True):
|
| 328 |
gr.HTML(build_visual_grammar_html())
|
| 329 |
|
| 330 |
+
with gr.TabItem("๐ Step-by-Step Trace", id="tab_trace"):
|
| 331 |
+
trace_output = gr.HTML(label="Step-by-step trace")
|
| 332 |
|
| 333 |
+
with gr.TabItem("๐ป Mermaid Code", id="tab_code"):
|
| 334 |
code_output = gr.Code(label="Mermaid Syntax", language="markdown")
|
| 335 |
+
with gr.TabItem("๐ Online Help", id="tab_help"):
|
| 336 |
gr.Markdown(
|
| 337 |
VISUAL_LANGUAGE + r"""
|
| 338 |
|
|
|
|
| 491 |
)
|
| 492 |
|
| 493 |
btn_diagram.click(
|
| 494 |
+
lambda *args: (gr.update(selected="tab_diagram"), *generate_diagram(*args)),
|
| 495 |
inputs=[expr_input, vals_input, mode_input, notation_input],
|
| 496 |
+
outputs=[main_tabs, diagram_output, code_output]
|
| 497 |
).then(
|
| 498 |
reset_downloads,
|
| 499 |
outputs=[download_pdf, download_png, download_svg]
|
| 500 |
)
|
| 501 |
|
| 502 |
btn_trace.click(
|
| 503 |
+
lambda *args: (gr.update(selected="tab_trace"), generate_trace(*args)),
|
| 504 |
inputs=[expr_input, vals_input, mode_input, notation_input],
|
| 505 |
+
outputs=[main_tabs, trace_output]
|
| 506 |
)
|
| 507 |
|
| 508 |
def load_initial_outputs(expr, vals, mode, notation):
|