Spaces:
Sleeping
Sleeping
Gabriela Nicole Gonzalez Saez
commited on
Commit
•
3774152
1
Parent(s):
ccb9751
en-sw
Browse files
app.py
CHANGED
@@ -19,36 +19,43 @@ from transformers import AutoTokenizer, MarianTokenizer, AutoModel, AutoModelFor
|
|
19 |
model_es = "Helsinki-NLP/opus-mt-en-es"
|
20 |
model_fr = "Helsinki-NLP/opus-mt-en-fr"
|
21 |
model_zh = "Helsinki-NLP/opus-mt-en-zh"
|
|
|
22 |
|
23 |
tokenizer_es = AutoTokenizer.from_pretrained(model_es)
|
24 |
tokenizer_fr = AutoTokenizer.from_pretrained(model_fr)
|
25 |
tokenizer_zh = AutoTokenizer.from_pretrained(model_zh)
|
|
|
26 |
|
27 |
model_tr_es = MarianMTModel.from_pretrained(model_es)
|
28 |
model_tr_fr = MarianMTModel.from_pretrained(model_fr)
|
29 |
model_tr_zh = MarianMTModel.from_pretrained(model_zh)
|
|
|
30 |
|
31 |
model_es = inseq.load_model("Helsinki-NLP/opus-mt-en-es", "input_x_gradient")
|
32 |
model_fr = inseq.load_model("Helsinki-NLP/opus-mt-en-fr", "input_x_gradient")
|
33 |
model_zh = inseq.load_model("Helsinki-NLP/opus-mt-en-zh", "input_x_gradient")
|
|
|
34 |
|
35 |
|
36 |
dict_models = {
|
37 |
'en-es': model_es,
|
38 |
'en-fr': model_fr,
|
39 |
'en-zh': model_zh,
|
|
|
40 |
}
|
41 |
|
42 |
dict_models_tr = {
|
43 |
'en-es': model_tr_es,
|
44 |
'en-fr': model_tr_fr,
|
45 |
'en-zh': model_tr_zh,
|
|
|
46 |
}
|
47 |
|
48 |
dict_tokenizer_tr = {
|
49 |
'en-es': tokenizer_es,
|
50 |
'en-fr': tokenizer_fr,
|
51 |
'en-zh': tokenizer_zh,
|
|
|
52 |
}
|
53 |
|
54 |
saliency_examples = [
|
@@ -227,7 +234,7 @@ with gr.Blocks(js="plotsjs.js") as demo:
|
|
227 |
out_text = gr.Textbox(label="target text")
|
228 |
out_text2 = gr.Textbox(visible=False)
|
229 |
var2 = gr.JSON(visible=False)
|
230 |
-
radio_c = gr.Radio(choices=['en-zh', 'en-es', 'en-fr'], value="en-zh", label= '', container=False)
|
231 |
btn = gr.Button("Translate")
|
232 |
input_mic = gr.HTML(html)
|
233 |
|
|
|
19 |
model_es = "Helsinki-NLP/opus-mt-en-es"
|
20 |
model_fr = "Helsinki-NLP/opus-mt-en-fr"
|
21 |
model_zh = "Helsinki-NLP/opus-mt-en-zh"
|
22 |
+
model_sw = "Helsinki-NLP/opus-mt-en-sw"
|
23 |
|
24 |
tokenizer_es = AutoTokenizer.from_pretrained(model_es)
|
25 |
tokenizer_fr = AutoTokenizer.from_pretrained(model_fr)
|
26 |
tokenizer_zh = AutoTokenizer.from_pretrained(model_zh)
|
27 |
+
tokenizer_sw = AutoTokenizer.from_pretrained(model_sw)
|
28 |
|
29 |
model_tr_es = MarianMTModel.from_pretrained(model_es)
|
30 |
model_tr_fr = MarianMTModel.from_pretrained(model_fr)
|
31 |
model_tr_zh = MarianMTModel.from_pretrained(model_zh)
|
32 |
+
model_tr_sw = MarianMTModel.from_pretrained(model_sw)
|
33 |
|
34 |
model_es = inseq.load_model("Helsinki-NLP/opus-mt-en-es", "input_x_gradient")
|
35 |
model_fr = inseq.load_model("Helsinki-NLP/opus-mt-en-fr", "input_x_gradient")
|
36 |
model_zh = inseq.load_model("Helsinki-NLP/opus-mt-en-zh", "input_x_gradient")
|
37 |
+
model_sw = inseq.load_model("Helsinki-NLP/opus-mt-en-sw", "input_x_gradient")
|
38 |
|
39 |
|
40 |
dict_models = {
|
41 |
'en-es': model_es,
|
42 |
'en-fr': model_fr,
|
43 |
'en-zh': model_zh,
|
44 |
+
'en-sw': model_sw,
|
45 |
}
|
46 |
|
47 |
dict_models_tr = {
|
48 |
'en-es': model_tr_es,
|
49 |
'en-fr': model_tr_fr,
|
50 |
'en-zh': model_tr_zh,
|
51 |
+
'en-sw': model_tr_sw,
|
52 |
}
|
53 |
|
54 |
dict_tokenizer_tr = {
|
55 |
'en-es': tokenizer_es,
|
56 |
'en-fr': tokenizer_fr,
|
57 |
'en-zh': tokenizer_zh,
|
58 |
+
'en-sw': tokenizer_sw,
|
59 |
}
|
60 |
|
61 |
saliency_examples = [
|
|
|
234 |
out_text = gr.Textbox(label="target text")
|
235 |
out_text2 = gr.Textbox(visible=False)
|
236 |
var2 = gr.JSON(visible=False)
|
237 |
+
radio_c = gr.Radio(choices=['en-zh', 'en-es', 'en-fr', 'en-sw'], value="en-zh", label= '', container=False)
|
238 |
btn = gr.Button("Translate")
|
239 |
input_mic = gr.HTML(html)
|
240 |
|