Spaces:
Runtime error
Runtime error
feat(interface): add project accordion state management
Browse files- add project_accordion_state to manage the open/close state of the project accordion
γUIγ
- update predict_button.click to include project_accordion_state in inputs and outputs
γBehaviorγ
- add project_accordion_state.change to update the accordion open/close state based on the project_accordion_state value
app.py
CHANGED
|
@@ -251,16 +251,18 @@ with gr.Blocks() as iface:
|
|
| 251 |
augment_checkboxgroup.change(lambda methods: gr.update(visible="add_noise" in methods), inputs=[augment_checkboxgroup], outputs=[noise_slider])
|
| 252 |
augment_checkboxgroup.change(lambda methods: gr.update(visible="sharpen" in methods), inputs=[augment_checkboxgroup], outputs=[sharpen_slider])
|
| 253 |
|
|
|
|
|
|
|
| 254 |
predict_button.click(
|
| 255 |
fn=predict_image_with_html,
|
| 256 |
-
inputs=inputs,
|
| 257 |
-
outputs=outputs
|
| 258 |
)
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
inputs=[],
|
| 263 |
-
outputs=[]
|
| 264 |
)
|
| 265 |
|
| 266 |
with gr.Tab("Another Interface"):
|
|
|
|
| 251 |
augment_checkboxgroup.change(lambda methods: gr.update(visible="add_noise" in methods), inputs=[augment_checkboxgroup], outputs=[noise_slider])
|
| 252 |
augment_checkboxgroup.change(lambda methods: gr.update(visible="sharpen" in methods), inputs=[augment_checkboxgroup], outputs=[sharpen_slider])
|
| 253 |
|
| 254 |
+
project_accordion_state = gr.State(value=True) # State to manage accordion open/close
|
| 255 |
+
|
| 256 |
predict_button.click(
|
| 257 |
fn=predict_image_with_html,
|
| 258 |
+
inputs=inputs + [project_accordion_state],
|
| 259 |
+
outputs=outputs + [project_accordion_state]
|
| 260 |
)
|
| 261 |
+
|
| 262 |
+
project_accordion_state.change(
|
| 263 |
+
lambda state: gr.update(open=state),
|
| 264 |
+
inputs=[project_accordion_state],
|
| 265 |
+
outputs=[project_accordion] # type: ignore
|
| 266 |
)
|
| 267 |
|
| 268 |
with gr.Tab("Another Interface"):
|