Update apps/gradio_app.py
Browse files- apps/gradio_app.py +9 -5
apps/gradio_app.py
CHANGED
|
@@ -28,8 +28,12 @@ examples = [
|
|
| 28 |
]
|
| 29 |
|
| 30 |
# Function to handle example selection
|
| 31 |
-
def select_example(
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
# Gradio Interface
|
| 35 |
with gr.Blocks(css=custom_css) as iface:
|
|
@@ -58,10 +62,10 @@ with gr.Blocks(css=custom_css) as iface:
|
|
| 58 |
examples_table = gr.Dataframe(
|
| 59 |
value=[[ex["Input File"], ex["Output File"], ex["Input Type"]] for ex in examples],
|
| 60 |
headers=["Input File", "Output File", "Input Type"],
|
| 61 |
-
interactive=
|
| 62 |
elem_classes="custom-table"
|
| 63 |
)
|
| 64 |
-
examples_table.
|
| 65 |
fn=select_example,
|
| 66 |
inputs=[examples_table, examples_table],
|
| 67 |
outputs=[input_file, input_type, output_image, output_video, output_text]
|
|
@@ -101,4 +105,4 @@ with gr.Blocks(css=custom_css) as iface:
|
|
| 101 |
)
|
| 102 |
|
| 103 |
if __name__ == "__main__":
|
| 104 |
-
iface.launch(
|
|
|
|
| 28 |
]
|
| 29 |
|
| 30 |
# Function to handle example selection
|
| 31 |
+
def select_example(selected_row, examples_data):
|
| 32 |
+
if selected_row is not None and isinstance(selected_row, list) and len(selected_row) > 0:
|
| 33 |
+
row_index = selected_row[0] # Get the index of the selected row
|
| 34 |
+
selected_example = examples[row_index]
|
| 35 |
+
return selected_example["Input File"], selected_example["Input Type"], None, None, None
|
| 36 |
+
return None, "Image", None, None, None # Default return if no row is selected
|
| 37 |
|
| 38 |
# Gradio Interface
|
| 39 |
with gr.Blocks(css=custom_css) as iface:
|
|
|
|
| 62 |
examples_table = gr.Dataframe(
|
| 63 |
value=[[ex["Input File"], ex["Output File"], ex["Input Type"]] for ex in examples],
|
| 64 |
headers=["Input File", "Output File", "Input Type"],
|
| 65 |
+
interactive=True, # Allow row selection
|
| 66 |
elem_classes="custom-table"
|
| 67 |
)
|
| 68 |
+
examples_table.change(
|
| 69 |
fn=select_example,
|
| 70 |
inputs=[examples_table, examples_table],
|
| 71 |
outputs=[input_file, input_type, output_image, output_video, output_text]
|
|
|
|
| 105 |
)
|
| 106 |
|
| 107 |
if __name__ == "__main__":
|
| 108 |
+
iface.launch()
|