Update app.py
Browse files
app.py
CHANGED
@@ -1,40 +1,32 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
def display_tree():
|
4 |
-
#
|
5 |
# Currently returns a simple string, but should be replaced with actual graph
|
6 |
return "Tree will be displayed here."
|
7 |
|
8 |
def display_image_based_on_dropdown_1(dropdown_value):
|
9 |
-
#
|
10 |
-
# Replace with actual logic to
|
11 |
return "Image based on dropdown 1 will be displayed here."
|
12 |
|
13 |
def display_image_based_on_dropdown_2(dropdown_value):
|
14 |
-
#
|
15 |
-
# Replace with actual logic to
|
16 |
return "Image based on dropdown 2 will be displayed here."
|
17 |
|
18 |
with gr.Blocks() as demo:
|
19 |
gr.Markdown("## Interactive Tree and Image Display")
|
20 |
|
21 |
with gr.Row():
|
22 |
-
tree_output = gr.Plot() #
|
23 |
|
24 |
with gr.Row():
|
25 |
with gr.Column():
|
26 |
dropdown_1 = gr.Dropdown(label="Select Option for Field 2", choices=["Option 1", "Option 2", "Option 3"])
|
27 |
-
image_output_1 = gr.Image()
|
28 |
with gr.Column():
|
29 |
dropdown_2 = gr.Dropdown(label="Select Option for Field 3", choices=["Option A", "Option B", "Option C"])
|
30 |
-
image_output_2 = gr.Image()
|
31 |
-
|
32 |
-
tree_output.update(value=display_tree())
|
33 |
-
image_output_1.update(value=display_image_based_on_dropdown_1(dropdown_1.value))
|
34 |
-
image_output_2.update(value=display_image_based_on_dropdown_2(dropdown_2.value))
|
35 |
-
|
36 |
-
# Interactive update when dropdown changes
|
37 |
-
dropdown_1.change(display_image_based_on_dropdown_1, inputs=[dropdown_1], outputs=[image_output_1])
|
38 |
-
dropdown_2.change(display_image_based_on_dropdown_2, inputs=[dropdown_2], outputs=[image_output_2])
|
39 |
|
40 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
def display_tree():
|
4 |
+
# This function should create and return a Plotly figure of the tree
|
5 |
# Currently returns a simple string, but should be replaced with actual graph
|
6 |
return "Tree will be displayed here."
|
7 |
|
8 |
def display_image_based_on_dropdown_1(dropdown_value):
|
9 |
+
# This function should return an image based on the dropdown value
|
10 |
+
# Replace with actual logic to display the image
|
11 |
return "Image based on dropdown 1 will be displayed here."
|
12 |
|
13 |
def display_image_based_on_dropdown_2(dropdown_value):
|
14 |
+
# This function should return an image based on the dropdown value
|
15 |
+
# Replace with actual logic to display the image
|
16 |
return "Image based on dropdown 2 will be displayed here."
|
17 |
|
18 |
with gr.Blocks() as demo:
|
19 |
gr.Markdown("## Interactive Tree and Image Display")
|
20 |
|
21 |
with gr.Row():
|
22 |
+
tree_output = gr.Plot(display_tree) # Connect the function directly
|
23 |
|
24 |
with gr.Row():
|
25 |
with gr.Column():
|
26 |
dropdown_1 = gr.Dropdown(label="Select Option for Field 2", choices=["Option 1", "Option 2", "Option 3"])
|
27 |
+
image_output_1 = gr.Image(fn=display_image_based_on_dropdown_1, inputs=dropdown_1)
|
28 |
with gr.Column():
|
29 |
dropdown_2 = gr.Dropdown(label="Select Option for Field 3", choices=["Option A", "Option B", "Option C"])
|
30 |
+
image_output_2 = gr.Image(fn=display_image_based_on_dropdown_2, inputs=dropdown_2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
demo.launch()
|