Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,24 +17,24 @@ flores_codes["Galego"] = "glg_Latn"
|
|
17 |
|
18 |
def translation(source, target, text):
|
19 |
|
20 |
-
start_time = time.time()
|
21 |
source = flores_codes[source]
|
22 |
target = flores_codes[target]
|
23 |
|
24 |
translator = pipeline('translation', model=model, tokenizer=tokenizer,
|
25 |
|
26 |
-
src_lang=source, tgt_lang=target)
|
27 |
output = translator(text, max_length=400)
|
28 |
|
29 |
-
end_time = time.time()
|
30 |
|
31 |
output = output[0]['translation_text']
|
32 |
-
result = {'inference_time': end_time - start_time,
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
return result
|
37 |
-
|
38 |
|
39 |
if __name__ == '__main__':
|
40 |
print('\tIniciando...')
|
@@ -42,20 +42,21 @@ if __name__ == '__main__':
|
|
42 |
|
43 |
# define gradio demo
|
44 |
lang_codes = list(flores_codes.keys())
|
45 |
-
inputs = [gr.Dropdown(lang_codes, value='Castellano', label='
|
46 |
-
gr.Dropdown(lang_codes, value='Asturianu', label='
|
47 |
-
gr.Textbox(label="
|
48 |
]
|
49 |
|
50 |
-
outputs = gr.
|
51 |
|
52 |
title = "Traductor Multilingüe"
|
53 |
|
54 |
-
description = """Este traductor utiliza el siguiente modelo de lenguaje de
|
55 |
-
|
56 |
-
Meta:
|
57 |
https://github.com/facebookresearch/fairseq/tree/nllb
|
|
|
58 |
Adaptado de:
|
|
|
59 |
https://huggingface.co/spaces/Azwaw/Text_Translation_Multi-languages"""
|
60 |
|
61 |
|
|
|
17 |
|
18 |
def translation(source, target, text):
|
19 |
|
20 |
+
#start_time = time.time()
|
21 |
source = flores_codes[source]
|
22 |
target = flores_codes[target]
|
23 |
|
24 |
translator = pipeline('translation', model=model, tokenizer=tokenizer,
|
25 |
|
26 |
+
src_lang=source, tgt_lang=target)
|
27 |
output = translator(text, max_length=400)
|
28 |
|
29 |
+
#end_time = time.time()
|
30 |
|
31 |
output = output[0]['translation_text']
|
32 |
+
#result = {'inference_time': end_time - start_time,
|
33 |
+
# 'source': source,
|
34 |
+
# 'target': target,
|
35 |
+
# 'result': output}
|
36 |
+
#return result
|
37 |
+
return output;
|
38 |
|
39 |
if __name__ == '__main__':
|
40 |
print('\tIniciando...')
|
|
|
42 |
|
43 |
# define gradio demo
|
44 |
lang_codes = list(flores_codes.keys())
|
45 |
+
inputs = [gr.Dropdown(lang_codes, value='Castellano', label='Idioma original'),
|
46 |
+
gr.Dropdown(lang_codes, value='Asturianu', label='Traducir al...'),
|
47 |
+
gr.Textbox(label="Texto a traducir"),
|
48 |
]
|
49 |
|
50 |
+
outputs = [gr.Textbox(label="Texto traducido"),]
|
51 |
|
52 |
title = "Traductor Multilingüe"
|
53 |
|
54 |
+
description = """Este traductor utiliza el siguiente modelo de lenguaje de Meta:
|
55 |
+
|
|
|
56 |
https://github.com/facebookresearch/fairseq/tree/nllb
|
57 |
+
|
58 |
Adaptado de:
|
59 |
+
|
60 |
https://huggingface.co/spaces/Azwaw/Text_Translation_Multi-languages"""
|
61 |
|
62 |
|