sanbo1200 commited on
Commit
26c5e57
1 Parent(s): 386bdc2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -1,3 +1,21 @@
1
  import gradio as gr
2
 
3
- gr.load("models/Helsinki-NLP/opus-mt-en-zh").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ gr.load("").launch()
4
+
5
+ from transformers import pipeline
6
+
7
+ pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-zh")
8
+
9
+ def predict(text):
10
+ return pipe(text)[0]["translation_text"]
11
+
12
+ title = "English to Chinese Translation"
13
+
14
+ iface = gr.Interface(
15
+ fn=predict,
16
+ inputs=[gr.Textbox(label="text", lines=3)],
17
+ outputs='text',
18
+ title=title,
19
+ )
20
+
21
+ iface.launch()