Spaces:
Running
Running
Anthony Liang commited on
Commit ·
6fd468d
1
Parent(s): d70a728
update app with sidebar
Browse files596 unmodified lines59759859960060160260360460560660760860961061161261361461561661761861962087 unmodified lines70870971071171271371471571671771871972072172238 unmodified lines761762763764765766767768769770771772773735 unmodified lines150915101511151215131514596 unmodified lines# Create Gradio interfacetry:# Try with theme (Gradio 4.0+)demo = gr.Blocks(title="RFM Evaluation Server", theme=gr.themes.Soft())except TypeError:# Fallback for older Gradio versions without theme supportdemo = gr.Blocks(title="RFM Evaluation Server")with demo:# Header with title and toggle buttonwith gr.Row():sidebar_toggle_btn = gr.Button("☰ Toggle Sidebar", variant="secondary", size="sm", elem_id="sidebar-toggle")gr.Markdown("""# RFM (Reward Foundation Model) Evaluation Server""",elem_id="main-title",)# Hidden state to store server URL and model mapping (define before use)server_url_state = gr.State(value=None)87 unmodified linesnew_visible = not visiblebutton_text = "☰ Show Sidebar" if not new_visible else "☰ Hide Sidebar"return (new_visible,gr.update(visible=new_visible),gr.update(value=button_text),)# Main layout with sidebar and content areawith gr.Row():# Sidebar for model selection and info (controlled by visibility state)sidebar_column = gr.Column(scale=1, min_width=300, visible=True)with sidebar_column:gr.Markdown("### 🔧 Model Configuration")38 unmodified lines# Main content area with tabswith gr.Column(scale=4):# Wire up the toggle buttonsidebar_toggle_btn.click(fn=toggle_sidebar,inputs=[sidebar_visible_state],outputs=[sidebar_visible_state, sidebar_column, sidebar_toggle_btn],)with gr.Tabs():with gr.Tab("Progress Prediction"):gr.Markdown("### Progress & Success Prediction")735 unmodified linesapi_name="process_two_videos",)def main():"""Launch the Gradio app."""596 unmodified lines59759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464587 unmodified lines73373473573673773873974074174274374474574674738 unmodified lines786787788789790791735 unmodified lines1527152815291530153115321533153415351536153715381539596 unmodified lines# Custom CSS for collapsible sidebarcustom_css = """#sidebar-toggle {position: sticky;top: 10px;z-index: 1000;margin-bottom: 10px;}/* Make sidebar full height */.gradio-container .gradio-row:has(#sidebar-column) {min-height: calc(100vh - 200px);}/* Smooth transition for sidebar (if supported) */#sidebar-column {transition: width 0.3s ease;}"""# Create Gradio interfacetry:# Try with theme (Gradio 4.0+)demo = gr.Blocks(title="RFM Evaluation Server", theme=gr.themes.Soft(), css=custom_css)except TypeError:# Fallback for older Gradio versions without theme supporttry:demo = gr.Blocks(title="RFM Evaluation Server", css=custom_css)except TypeError:# Even older versions may not support css parameterdemo = gr.Blocks(title="RFM Evaluation Server")with demo:# Header with title and toggle buttonwith gr.Row():sidebar_toggle_btn = gr.Button("☰ Hide Sidebar", variant="secondary", size="sm", elem_id="sidebar-toggle", scale=0)with gr.Column(scale=1):gr.Markdown("""# RFM (Reward Foundation Model) Evaluation Server""",elem_id="main-title",)# Hidden state to store server URL and model mapping (define before use)server_url_state = gr.State(value=None)87 unmodified linesnew_visible = not visiblebutton_text = "☰ Show Sidebar" if not new_visible else "☰ Hide Sidebar"return (new_visible, # Update stategr.update(visible=new_visible), # Update sidebar visibilitygr.update(value=button_text), # Update button text)# Main layout with sidebar and content areawith gr.Row():# Sidebar for model selection and info (controlled by visibility state)sidebar_column = gr.Column(scale=1, min_width=300, visible=True, elem_id="sidebar-column")with sidebar_column:gr.Markdown("### 🔧 Model Configuration")38 unmodified lines# Main content area with tabswith gr.Column(scale=4):with gr.Tabs():with gr.Tab("Progress Prediction"):gr.Markdown("### Progress & Success Prediction")735 unmodified linesapi_name="process_two_videos",)# Wire up the sidebar toggle button (can be anywhere in the demo block)sidebar_toggle_btn.click(fn=toggle_sidebar,inputs=[sidebar_visible_state],outputs=[sidebar_visible_state, sidebar_column, sidebar_toggle_btn],)def main():"""Launch the Gradio app."""
app.py+45-20