Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
pipe = pipeline("translation", model = "Helsinki-NLP/opus-mt-en-es")
|
5 |
+
|
6 |
+
def predict(text):
|
7 |
+
return pipe(text)[0]["translation_text"]
|
8 |
+
|
9 |
+
title ="Interactive demo: Helsinki-NLP English to Spanish Translator"
|
10 |
+
|
11 |
+
iface = gr.Interface(
|
12 |
+
fn=predict,
|
13 |
+
inputs=gr.Textbox(lines = 3, placeholder = "text"),
|
14 |
+
outputs='text',
|
15 |
+
title=title,
|
16 |
+
examples = [["Hello! My name is Alex"], ["I like this class"]]
|
17 |
+
)
|
18 |
+
iface.launch(debug = True)
|