diogocarapito commited on
Commit
c72b9d8
·
1 Parent(s): e451c49

trasformers test

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -1,8 +1,17 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  iface.launch()
8
 
 
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
+ iface = gr.Interface(
10
+ fn=predict,
11
+ inputs='text',
12
+ outputs='text',
13
+ examples=[["Hello! My name is Omar"]]
14
+ )
15
 
 
16
  iface.launch()
17