murongtianfeng commited on
Commit
fb43ba9
·
1 Parent(s): cd1f566

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -10
app.py CHANGED
@@ -1,16 +1,23 @@
1
  import gradio as gr
2
 
3
- from transformers import pipeline
4
-
5
- pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es")
6
-
7
- def predict(text):
8
- return pipe(text)[0]["translation_text"]
 
 
 
9
 
10
  demo = gr.Interface(
11
- fn=predict,
12
- inputs='text',
13
- outputs='text',
 
 
 
 
 
14
  )
15
-
16
  demo.launch()
 
1
  import gradio as gr
2
 
3
+ def calculator(num1, operation, num2):
4
+ if operation == "add":
5
+ return num1 + num2
6
+ elif operation == "subtract":
7
+ return num1 - num2
8
+ elif operation == "multiply":
9
+ return num1 * num2
10
+ elif operation == "divide":
11
+ return num1 / num2
12
 
13
  demo = gr.Interface(
14
+ calculator,
15
+ [
16
+ "number",
17
+ gr.Radio(["add", "subtract", "multiply", "divide"]),
18
+ "number"
19
+ ],
20
+ "number",
21
+ live=True,
22
  )
 
23
  demo.launch()