AlexD108 commited on
Commit
91ae113
1 Parent(s): 7fa53af

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
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)