Spaces:
Runtime error
Runtime error
Commit
·
bd80753
1
Parent(s):
3fad6dd
Upload app.py with huggingface_hub
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
title = "English to Spanish Translation (forked from osanseviero/test_gradio)"
|
| 11 |
+
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=predict,
|
| 14 |
+
inputs=[gr.inputs.Textbox(label="text", lines=3)],
|
| 15 |
+
outputs='text',
|
| 16 |
+
title=title,
|
| 17 |
+
examples=[["Hello! My name is Abubakar"], ["How are you?"]]
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
iface.launch()
|