Spaces:
Runtime error
Runtime error
Commit
·
c92d580
1
Parent(s):
3a655e3
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,43 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Step 6.1: Define different input components
|
2 |
import gradio as gr
|
3 |
|
4 |
+
# a. define text data type
|
5 |
+
input_module1 = gr.inputs.Textbox(label = "Input Text")
|
6 |
+
|
7 |
+
# b. define image data type
|
8 |
+
input_module2 = gr.inputs.Image(label = "Input Image")
|
9 |
+
|
10 |
+
# c. define Number data type
|
11 |
+
input_module3 = gr.inputs.Number(label = "Input Number")
|
12 |
+
|
13 |
+
# d. define Slider data type
|
14 |
+
input_module4 = gr.inputs.Slider(1, 100, step=5, label = "Input Slider")
|
15 |
+
|
16 |
+
# e. define Checkbox data type
|
17 |
+
input_module5 = gr.inputs.Checkbox(label = "Does it work?")
|
18 |
+
|
19 |
+
# f. define Radio data type
|
20 |
+
input_module6 = gr.inputs.Radio(choices=["park", "zoo", "road"], label = "Input Radio")
|
21 |
+
|
22 |
+
# g. define Dropdown data type
|
23 |
+
input_module7 = gr.inputs.Dropdown(choices=["park", "zoo", "road"], label = "Input Dropdown")
|
24 |
+
# Step 6.2: Define different output components
|
25 |
+
# a. define text data type
|
26 |
+
output_module1 = gr.outputs.Textbox(label = "Output Text")
|
27 |
+
|
28 |
+
# b. define image data type
|
29 |
+
output_module2 = gr.outputs.Image(label = "Output Image")
|
30 |
+
def multi_inputs(input1, input2, input3, input4, input5, input6, input7 ):
|
31 |
+
import numpy as np
|
32 |
+
## processing inputs
|
33 |
+
|
34 |
+
## return outputs
|
35 |
+
output1 = "Processing inputs and return outputs" # text output example
|
36 |
+
output2 = np.random.rand(6,6) # image-like array output example
|
37 |
+
return output1,output2
|
38 |
+
gr.Interface(fn=multi_inputs,
|
39 |
+
inputs=[input_module1, input_module2, input_module3,
|
40 |
+
input_module4, input_module5, input_module6,
|
41 |
+
input_module7],
|
42 |
+
outputs=[output_module1, output_module2]
|
43 |
+
).launch()
|