File size: 1,793 Bytes
c92d580
db1db33
b469760
c92d580
1a0224a
c92d580
 
1a0224a
c92d580
 
1a0224a
c92d580
 
3a8e72c
c92d580
 
1a0224a
c92d580
 
1a0224a
c92d580
 
1a0224a
c92d580
 
1a0224a
c92d580
 
3a8e72c
1a0224a
 
 
c92d580
 
 
 
 
 
 
 
1a0224a
c92d580
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Step 6.1: Define different input components
import gradio as gr

# a. define text data type
input_module1 = gr.inputs.Textbox(label = "Input Text")

# b. define image data type
input_module2 = gr.inputs.Image(label = "Input Image")

# c. define Number data type
input_module3 = gr.inputs.Number(label = "Input Number")

# d. define Slider data type
input_module4 = gr.inputs.Slider(minimum=1,maximum=100, step=5, label = "Input Slider")

# e. define Checkbox data type
input_module5 = gr.inputs.Checkbox(label = "Does it work?")

# f. define Radio data type
input_module6 = gr.inputs.Radio(choices=["park", "zoo", "road"], label = "Input Radio")

# g. define Dropdown data type
input_module7 = gr.inputs.Dropdown(choices=["park", "zoo", "road"], label = "Input Dropdown")
# Step 6.2: Define different output components
# a. define text data type
output_module1 = gr.outputs.Textbox(label = "Output Text")

# b. define image data type
output_module2 = gr.outputs.Image(type="pil",label = "Output Image")

# you can define more output components
# Step 6.3: Define a new function that accommodates the input modules.
def multi_inputs(input1, input2, input3, input4, input5, input6, input7 ):
    import numpy as np
    ## processing inputs

    ## return outputs
    output1 = "Processing inputs and return outputs" # text output example
    output2 = np.random.rand(6,6) # image-like array output example
    return output1,output2
# Step 6.4: Put all three component together into the gradio's interface function 
gr.Interface(fn=multi_inputs, 
             inputs=[input_module1, input_module2, input_module3,
                     input_module4, input_module5, input_module6,
                     input_module7], 
             outputs=[output_module1, output_module2]
            ).launch()