osanseviero HF staff commited on
Commit
5a5f048
1 Parent(s): b4ccf5b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Translation"
10
+
11
+ iface = gr.Interface(
12
+ fn=predict,
13
+ inputs=[gr.inputs.Textbox(label="text", lines=3)],
14
+ outputs='text',
15
+ title=title,
16
+ examples=[["Hello! My name is Omar"], ["I like this workshop"]]
17
+ ).launch(debug=True)