Sebastien De Greef commited on
Commit
4af8a78
1 Parent(s): 3cf528f

chore: Add Gradio interface for processing input

Browse files
Files changed (1) hide show
  1. app.py +29 -4
app.py CHANGED
@@ -1,7 +1,32 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ def process_input(model_name, checkbox1, checkbox2, text1, text2):
4
+ result = f"Model: {model_name}\nCheckbox 1: {checkbox1}\nCheckbox 2: {checkbox2}\nText Field 1: {text1}\nText Field 2: {text2}"
5
+ return result
6
 
7
+ # Dropdown options
8
+ model_options = ["Model A", "Model B", "Model C"]
9
+
10
+ # Create the Gradio interface
11
+ with gr.Blocks() as demo:
12
+ gr.Markdown("## Gradio Interface Example")
13
+
14
+ # Dropdown for model_name
15
+ model_name = gr.Dropdown(choices=model_options, label="Select Model")
16
+
17
+ # Checkboxes
18
+ checkbox1 = gr.Checkbox(label="Checkbox 1")
19
+ checkbox2 = gr.Checkbox(label="Checkbox 2")
20
+
21
+ # Text fields
22
+ text1 = gr.Textbox(label="Text Field 1")
23
+ text2 = gr.Textbox(label="Text Field 2")
24
+
25
+ # Output
26
+ output = gr.Textbox(label="Output")
27
+
28
+ # Button to submit and process the input
29
+ submit_btn = gr.Button("Submit")
30
+ submit_btn.click(process_input, inputs=[model_name, checkbox1, checkbox2, text1, text2], outputs=output)
31
+
32
+ demo.launch()