feng2022 commited on
Commit
972a2bf
1 Parent(s): 6d66f22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -6
app.py CHANGED
@@ -24,9 +24,18 @@ ARTICLE = '<center><img src="https://visitor-badge.glitch.me/badge?page_id=hysts
24
 
25
  TOKEN = "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"
26
 
27
- gr.Interface(
28
- title=TITLE,
29
- description=DESCRIPTION,
30
- article=ARTICLE,
31
- ).launch(enable_queue=True)
32
-
 
 
 
 
 
 
 
 
 
 
24
 
25
  TOKEN = "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"
26
 
27
+ from transformers import pipeline
28
+
29
+ pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es")
30
+
31
+ def predict(text):
32
+ return pipe(text)[0]["translation_text"]
33
+
34
+ iface = gr.Interface(
35
+ fn=predict,
36
+ inputs='text',
37
+ outputs='text',
38
+ examples=[["Hello! My name is Omar"]]
39
+ )
40
+
41
+ iface.launch()