Pankeke14 commited on
Commit
8ac6dec
·
verified ·
1 Parent(s): b64baf3

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 Translator"
10
+
11
+ iface = gr.Interface(
12
+ fn=predict,
13
+ inputs=gr.Textbox(lines = 3, placeholder = "text"),
14
+ outputs='text', t
15
+ itle=title,
16
+ examples = [["Hello! My name is Alex"], ["I like this class"]] )
17
+ iface.launch(debug = True)