serJD commited on
Commit
fe11de6
·
verified ·
1 Parent(s): e0c0acc

upload initial files v1

Browse files
Files changed (2) hide show
  1. app.py +58 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas
3
+ import PIL
4
+
5
+
6
+ # Dummy function for Workflow A
7
+ def workflow_a(image, text):
8
+ # Here you might process the image/text in a specific way.
9
+ return "Workflow A executed!"
10
+
11
+
12
+ # Dummy function for Workflow B
13
+ def workflow_b(image, text):
14
+ # Here you might process the image/text in a different way.
15
+ return "Workflow B executed!"
16
+
17
+ # Main function triggered by the Start button.
18
+ # It uses an if statement to decide which workflow to call.
19
+ def main(image, text):
20
+ # Example condition: if the text (after stripping whitespace) equals "a" (case-insensitive), call workflow_a.
21
+ if text.strip().lower() == "a":
22
+ result_text = workflow_a(image, text)
23
+ else:
24
+ result_text = workflow_b(image, text)
25
+
26
+ # Forward the input image to both image outputs.
27
+ return image, image,
28
+
29
+
30
+ # Build the Gradio interface using Blocks for a custom layout.
31
+ with gr.Blocks() as demo:
32
+ gr.Markdown("## Gradio Demo: Workflow Selector")
33
+
34
+ # Input components in a row.
35
+ with gr.Row():
36
+ image_input = gr.Image(label="Input Image")
37
+ text_input = gr.Textbox(label="Input Text", placeholder='Type "a" for workflow A or anything else for workflow B')
38
+
39
+ # Start button to trigger the main function.
40
+ start_button = gr.Button("Start")
41
+
42
+ gr.Markdown("### Outputs")
43
+ # Output images in a row.
44
+ with gr.Row():
45
+ output_image1 = gr.Image(label="Output Image 1")
46
+ output_image2 = gr.Image(label="Output Image 2")
47
+
48
+ output_text = gr.Textbox(label="Output Text")
49
+
50
+ # Connect the Start button to the main function.
51
+ start_button.click(
52
+ fn=main,
53
+ inputs=[image_input, text_input],
54
+ outputs=[output_image1, output_image2, output_text]
55
+ )
56
+
57
+ # Launch the Gradio app.
58
+ demo.launch(share=True)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ pandas
3
+ PIL