Spaces:
Runtime error
Runtime error
Commit
·
1a0224a
1
Parent(s):
6502f81
Update app.py
Browse files
app.py
CHANGED
@@ -2,31 +2,34 @@
|
|
2 |
import gradio as gr
|
3 |
|
4 |
# a. define text data type
|
5 |
-
input_module1 = gr.
|
6 |
|
7 |
# b. define image data type
|
8 |
-
input_module2 = gr.
|
9 |
|
10 |
# c. define Number data type
|
11 |
-
input_module3 = gr.
|
12 |
|
13 |
# d. define Slider data type
|
14 |
-
input_module4 = gr.
|
15 |
|
16 |
# e. define Checkbox data type
|
17 |
-
input_module5 = gr.
|
18 |
|
19 |
# f. define Radio data type
|
20 |
-
input_module6 = gr.
|
21 |
|
22 |
# g. define Dropdown data type
|
23 |
-
input_module7 = gr.
|
24 |
# Step 6.2: Define different output components
|
25 |
# a. define text data type
|
26 |
-
output_module1 = gr.
|
27 |
|
28 |
# b. define image data type
|
29 |
-
output_module2 = gr.
|
|
|
|
|
|
|
30 |
def multi_inputs(input1, input2, input3, input4, input5, input6, input7 ):
|
31 |
import numpy as np
|
32 |
## processing inputs
|
@@ -35,6 +38,7 @@ def multi_inputs(input1, input2, input3, input4, input5, input6, input7 ):
|
|
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,
|
|
|
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 |
+
|
31 |
+
# you can define more output components
|
32 |
+
# Step 6.3: Define a new function that accommodates the input modules.
|
33 |
def multi_inputs(input1, input2, input3, input4, input5, input6, input7 ):
|
34 |
import numpy as np
|
35 |
## processing inputs
|
|
|
38 |
output1 = "Processing inputs and return outputs" # text output example
|
39 |
output2 = np.random.rand(6,6) # image-like array output example
|
40 |
return output1,output2
|
41 |
+
# Step 6.4: Put all three component together into the gradio's interface function
|
42 |
gr.Interface(fn=multi_inputs,
|
43 |
inputs=[input_module1, input_module2, input_module3,
|
44 |
input_module4, input_module5, input_module6,
|