Spaces:
Running
Running
Anthony Liang commited on
Commit ·
6fd468d
1
Parent(s): d70a728
update app with sidebar
Browse files
app.py
CHANGED
|
@@ -597,24 +597,49 @@ def process_two_videos(
|
|
| 597 |
|
| 598 |
|
| 599 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 600 |
# Create Gradio interface
|
| 601 |
try:
|
| 602 |
# Try with theme (Gradio 4.0+)
|
| 603 |
-
demo = gr.Blocks(title="RFM Evaluation Server", theme=gr.themes.Soft())
|
| 604 |
except TypeError:
|
| 605 |
# Fallback for older Gradio versions without theme support
|
| 606 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 607 |
|
| 608 |
with demo:
|
| 609 |
# Header with title and toggle button
|
| 610 |
with gr.Row():
|
| 611 |
-
sidebar_toggle_btn = gr.Button("☰
|
| 612 |
-
gr.
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
|
|
|
| 618 |
|
| 619 |
# Hidden state to store server URL and model mapping (define before use)
|
| 620 |
server_url_state = gr.State(value=None)
|
|
@@ -708,15 +733,15 @@ with demo:
|
|
| 708 |
new_visible = not visible
|
| 709 |
button_text = "☰ Show Sidebar" if not new_visible else "☰ Hide Sidebar"
|
| 710 |
return (
|
| 711 |
-
new_visible,
|
| 712 |
-
gr.update(visible=new_visible),
|
| 713 |
-
gr.update(value=button_text),
|
| 714 |
)
|
| 715 |
|
| 716 |
# Main layout with sidebar and content area
|
| 717 |
with gr.Row():
|
| 718 |
# Sidebar for model selection and info (controlled by visibility state)
|
| 719 |
-
sidebar_column = gr.Column(scale=1, min_width=300, visible=True)
|
| 720 |
with sidebar_column:
|
| 721 |
gr.Markdown("### 🔧 Model Configuration")
|
| 722 |
|
|
@@ -761,13 +786,6 @@ with demo:
|
|
| 761 |
|
| 762 |
# Main content area with tabs
|
| 763 |
with gr.Column(scale=4):
|
| 764 |
-
# Wire up the toggle button
|
| 765 |
-
sidebar_toggle_btn.click(
|
| 766 |
-
fn=toggle_sidebar,
|
| 767 |
-
inputs=[sidebar_visible_state],
|
| 768 |
-
outputs=[sidebar_visible_state, sidebar_column, sidebar_toggle_btn],
|
| 769 |
-
)
|
| 770 |
-
|
| 771 |
with gr.Tabs():
|
| 772 |
with gr.Tab("Progress Prediction"):
|
| 773 |
gr.Markdown("### Progress & Success Prediction")
|
|
@@ -1509,6 +1527,13 @@ with demo:
|
|
| 1509 |
api_name="process_two_videos",
|
| 1510 |
)
|
| 1511 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1512 |
|
| 1513 |
def main():
|
| 1514 |
"""Launch the Gradio app."""
|
|
|
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
+
# Custom CSS for collapsible sidebar
|
| 601 |
+
custom_css = """
|
| 602 |
+
#sidebar-toggle {
|
| 603 |
+
position: sticky;
|
| 604 |
+
top: 10px;
|
| 605 |
+
z-index: 1000;
|
| 606 |
+
margin-bottom: 10px;
|
| 607 |
+
}
|
| 608 |
+
|
| 609 |
+
/* Make sidebar full height */
|
| 610 |
+
.gradio-container .gradio-row:has(#sidebar-column) {
|
| 611 |
+
min-height: calc(100vh - 200px);
|
| 612 |
+
}
|
| 613 |
+
|
| 614 |
+
/* Smooth transition for sidebar (if supported) */
|
| 615 |
+
#sidebar-column {
|
| 616 |
+
transition: width 0.3s ease;
|
| 617 |
+
}
|
| 618 |
+
"""
|
| 619 |
+
|
| 620 |
# Create Gradio interface
|
| 621 |
try:
|
| 622 |
# Try with theme (Gradio 4.0+)
|
| 623 |
+
demo = gr.Blocks(title="RFM Evaluation Server", theme=gr.themes.Soft(), css=custom_css)
|
| 624 |
except TypeError:
|
| 625 |
# Fallback for older Gradio versions without theme support
|
| 626 |
+
try:
|
| 627 |
+
demo = gr.Blocks(title="RFM Evaluation Server", css=custom_css)
|
| 628 |
+
except TypeError:
|
| 629 |
+
# Even older versions may not support css parameter
|
| 630 |
+
demo = gr.Blocks(title="RFM Evaluation Server")
|
| 631 |
|
| 632 |
with demo:
|
| 633 |
# Header with title and toggle button
|
| 634 |
with gr.Row():
|
| 635 |
+
sidebar_toggle_btn = gr.Button("☰ Hide Sidebar", variant="secondary", size="sm", elem_id="sidebar-toggle", scale=0)
|
| 636 |
+
with gr.Column(scale=1):
|
| 637 |
+
gr.Markdown(
|
| 638 |
+
"""
|
| 639 |
+
# RFM (Reward Foundation Model) Evaluation Server
|
| 640 |
+
""",
|
| 641 |
+
elem_id="main-title",
|
| 642 |
+
)
|
| 643 |
|
| 644 |
# Hidden state to store server URL and model mapping (define before use)
|
| 645 |
server_url_state = gr.State(value=None)
|
|
|
|
| 733 |
new_visible = not visible
|
| 734 |
button_text = "☰ Show Sidebar" if not new_visible else "☰ Hide Sidebar"
|
| 735 |
return (
|
| 736 |
+
new_visible, # Update state
|
| 737 |
+
gr.update(visible=new_visible), # Update sidebar visibility
|
| 738 |
+
gr.update(value=button_text), # Update button text
|
| 739 |
)
|
| 740 |
|
| 741 |
# Main layout with sidebar and content area
|
| 742 |
with gr.Row():
|
| 743 |
# Sidebar for model selection and info (controlled by visibility state)
|
| 744 |
+
sidebar_column = gr.Column(scale=1, min_width=300, visible=True, elem_id="sidebar-column")
|
| 745 |
with sidebar_column:
|
| 746 |
gr.Markdown("### 🔧 Model Configuration")
|
| 747 |
|
|
|
|
| 786 |
|
| 787 |
# Main content area with tabs
|
| 788 |
with gr.Column(scale=4):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 789 |
with gr.Tabs():
|
| 790 |
with gr.Tab("Progress Prediction"):
|
| 791 |
gr.Markdown("### Progress & Success Prediction")
|
|
|
|
| 1527 |
api_name="process_two_videos",
|
| 1528 |
)
|
| 1529 |
|
| 1530 |
+
# Wire up the sidebar toggle button (can be anywhere in the demo block)
|
| 1531 |
+
sidebar_toggle_btn.click(
|
| 1532 |
+
fn=toggle_sidebar,
|
| 1533 |
+
inputs=[sidebar_visible_state],
|
| 1534 |
+
outputs=[sidebar_visible_state, sidebar_column, sidebar_toggle_btn],
|
| 1535 |
+
)
|
| 1536 |
+
|
| 1537 |
|
| 1538 |
def main():
|
| 1539 |
"""Launch the Gradio app."""
|