George Tsang
commited on
Commit
·
5918aab
1
Parent(s):
ddaafa1
change to translator
Browse files
app.py
CHANGED
@@ -1,14 +1,8 @@
|
|
1 |
-
from transformers import
|
2 |
import gradio as grad
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
text= "{"+"'question': '"+question+"','context': '"+context+"'}"
|
10 |
-
di=ast.literal_eval(text)
|
11 |
-
response = my_pipeline(di)
|
12 |
-
return response
|
13 |
-
|
14 |
-
grad.Interface(answer_question, inputs=["text","text"], outputs="text").launch()
|
|
|
1 |
+
from transformers import pipeline
|
2 |
import gradio as grad
|
3 |
+
mdl_name = "Helsinki-NLP/opus-mt-en-de"
|
4 |
+
opus_translator = pipeline("translation", model=mdl_name)
|
5 |
+
def translate(text):
|
6 |
+
response = opus_translator(text)
|
7 |
+
return response
|
8 |
+
grad.Interface(translate, inputs=["text",], outputs="text").launch()
|
|
|
|
|
|
|
|
|
|
|
|