Update app.py
Browse files
app.py
CHANGED
@@ -3,13 +3,14 @@ import gradio as grad
|
|
3 |
mdl_name = "Helsinki-NLP/opus-mt-en-de"
|
4 |
mdl = AutoModelForSeq2SeqLM.from_pretrained(mdl_name)
|
5 |
my_tkn = AutoTokenizer.from_pretrained(mdl_name)
|
|
|
6 |
#opus_translator = pipeline("translation", model=mdl_name)
|
|
|
7 |
def translate(text):
|
8 |
inputs = my_tkn(text, return_tensors="pt")
|
9 |
trans_output = mdl.generate(**inputs)
|
10 |
-
response = my_tkn.decode(trans_output[0],
|
11 |
-
|
12 |
#response = opus_translator(text)
|
13 |
return response
|
14 |
-
grad.Interface(translate, inputs=["text",], outputs="text").
|
15 |
-
launch()
|
|
|
3 |
mdl_name = "Helsinki-NLP/opus-mt-en-de"
|
4 |
mdl = AutoModelForSeq2SeqLM.from_pretrained(mdl_name)
|
5 |
my_tkn = AutoTokenizer.from_pretrained(mdl_name)
|
6 |
+
|
7 |
#opus_translator = pipeline("translation", model=mdl_name)
|
8 |
+
|
9 |
def translate(text):
|
10 |
inputs = my_tkn(text, return_tensors="pt")
|
11 |
trans_output = mdl.generate(**inputs)
|
12 |
+
response = my_tkn.decode(trans_output[0], skip_special_tokens=True)
|
13 |
+
|
14 |
#response = opus_translator(text)
|
15 |
return response
|
16 |
+
grad.Interface(translate, inputs=["text",], outputs="text").launch()
|
|