Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
gr.load("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|