Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,10 +7,9 @@ from transformers import AutoTokenizer, pipeline
|
|
7 |
# Modelo de Meta capaz de traducir a más de 200 idiomas
|
8 |
model = 'facebook/nllb-200-distilled-600M'
|
9 |
tokenizer = model
|
10 |
-
# Pero como traduce mal al asturiano, añadimos este otro que traduce del español
|
11 |
# Es del proyecto AINA: https://huggingface.co/projecte-aina
|
12 |
model_ast = "projecte-aina/aina-translator-es-ast"
|
13 |
-
tokenizer_ast = model_ast
|
14 |
|
15 |
flores_codes = {}
|
16 |
flores_codes["Asturianu"] = "ast_Latn"
|
@@ -30,7 +29,7 @@ def translation(source, target, text):
|
|
30 |
if source != flores_codes["Castellano"]:
|
31 |
translator = pipeline('translation', model=model, tokenizer=tokenizer, src_lang=source, tgt_lang=flores_codes["Castellano"])
|
32 |
texto_castellano = translator(text, max_length=400)
|
33 |
-
translator_ast = pipeline('translation', model=model_ast, tokenizer=
|
34 |
output = translator_ast(text, max_length=400)
|
35 |
else:
|
36 |
translator = pipeline('translation', model=model, tokenizer=tokenizer, src_lang=source, tgt_lang=target)
|
@@ -73,5 +72,6 @@ if __name__ == '__main__':
|
|
73 |
outputs,
|
74 |
title=title,
|
75 |
description=description,
|
|
|
76 |
).launch()
|
77 |
|
|
|
7 |
# Modelo de Meta capaz de traducir a más de 200 idiomas
|
8 |
model = 'facebook/nllb-200-distilled-600M'
|
9 |
tokenizer = model
|
10 |
+
# Pero como traduce mal al asturiano, añadimos este otro fine-tuned que traduce del español
|
11 |
# Es del proyecto AINA: https://huggingface.co/projecte-aina
|
12 |
model_ast = "projecte-aina/aina-translator-es-ast"
|
|
|
13 |
|
14 |
flores_codes = {}
|
15 |
flores_codes["Asturianu"] = "ast_Latn"
|
|
|
29 |
if source != flores_codes["Castellano"]:
|
30 |
translator = pipeline('translation', model=model, tokenizer=tokenizer, src_lang=source, tgt_lang=flores_codes["Castellano"])
|
31 |
texto_castellano = translator(text, max_length=400)
|
32 |
+
translator_ast = pipeline('translation', model=model_ast, tokenizer=tokenizer)
|
33 |
output = translator_ast(text, max_length=400)
|
34 |
else:
|
35 |
translator = pipeline('translation', model=model, tokenizer=tokenizer, src_lang=source, tgt_lang=target)
|
|
|
72 |
outputs,
|
73 |
title=title,
|
74 |
description=description,
|
75 |
+
submit_btn="Traducir"
|
76 |
).launch()
|
77 |
|