Shawn commited on
Commit
bca8cc3
·
1 Parent(s): 6d92158

Add application file

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -1,7 +1,22 @@
1
  import gradio as gr
2
 
 
3
  def greet(name):
4
  return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ # 定义第一个接口
4
  def greet(name):
5
  return "Hello " + name + "!!"
6
 
7
+ iface_greet = gr.Interface(fn=greet, inputs="text", outputs="text", title="Greeting")
8
+
9
+ # 定义第二个接口
10
+ def count_numbers(n):
11
+ return len(str(n))
12
+
13
+ iface_count = gr.Interface(fn=count_numbers, inputs="number", outputs="number", title="Count Numbers")
14
+
15
+ # 将两个接口添加到接口组中
16
+ iface_group = gr.InterfaceGroup([iface_greet, iface_count], title="My Interfaces")
17
+
18
+ # 为第一个接口添加一个按钮,点击该按钮将切换到第二个接口
19
+ iface_greet.add_button("Count Numbers", interface=iface_count)
20
+
21
+ # 启动接口组
22
+ iface_group.launch()