Update app.py
Browse files
app.py
CHANGED
|
@@ -20,8 +20,11 @@ iso1_to_name = {iso[1]: iso[0] for iso in non_empty_isos} # {'ro': 'Romanian', '
|
|
| 20 |
langs = {iso[0]: iso[1] for iso in non_empty_isos} # {'Romanian': 'ro', 'German': 'de'}
|
| 21 |
|
| 22 |
|
| 23 |
-
models = ["Helsinki-NLP", "
|
| 24 |
-
"
|
|
|
|
|
|
|
|
|
|
| 25 |
allmodels = ["Helsinki-NLP",
|
| 26 |
"Helsinki-NLP/opus-mt-tc-bible-big-mul-mul", "Helsinki-NLP/opus-mt-tc-bible-big-mul-deu_eng_nld",
|
| 27 |
"Helsinki-NLP/opus-mt-tc-bible-big-mul-deu_eng_fra_por_spa", "Helsinki-NLP/opus-mt-tc-bible-big-deu_eng_fra_por_spa-mul",
|
|
@@ -34,11 +37,6 @@ allmodels = ["Helsinki-NLP",
|
|
| 34 |
"t5-small", "t5-base", "t5-large",
|
| 35 |
"google/flan-t5-small", "google/flan-t5-base", "google/flan-t5-large", "google/flan-t5-xl",
|
| 36 |
"google/madlad400-3b-mt", "jbochi/madlad400-3b-mt",
|
| 37 |
-
"Argos", "Google",
|
| 38 |
-
"HuggingFaceTB/SmolLM3-3B", "winninghealth/WiNGPT-Babel-2",
|
| 39 |
-
"utter-project/EuroLLM-1.7B", "utter-project/EuroLLM-1.7B-Instruct",
|
| 40 |
-
"Unbabel/Tower-Plus-2B", "Unbabel/TowerInstruct-7B-v0.2", "Unbabel/TowerInstruct-Mistral-7B-v0.2",
|
| 41 |
-
"openGPT-X/Teuken-7B-instruct-commercial-v0.4", "openGPT-X/Teuken-7B-instruct-v0.6"
|
| 42 |
]
|
| 43 |
class Translators:
|
| 44 |
def __init__(self, model_name: str, sl: str, tl: str, input_text: str):
|
|
@@ -115,8 +113,8 @@ class Translators:
|
|
| 115 |
message = f"Available models: {', '.join(quickmt_models)}"
|
| 116 |
return translation, message
|
| 117 |
|
| 118 |
-
@
|
| 119 |
-
def download_argos_model(
|
| 120 |
import argostranslate.package
|
| 121 |
print('Downloading model', from_code, to_code)
|
| 122 |
# Download and install Argos Translate package
|
|
@@ -139,7 +137,12 @@ class Translators:
|
|
| 139 |
except Exception as error:
|
| 140 |
translated_text = error
|
| 141 |
return translated_text
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
def HelsinkiNLP_mulroa(self):
|
| 144 |
try:
|
| 145 |
pipe = pipeline("translation", model=self.model_name, device=self.device)
|
|
@@ -544,6 +547,10 @@ def translate_text(model_name: str, s_language: str, t_language: str, input_text
|
|
| 544 |
|
| 545 |
elif model_name == "QUICKMT":
|
| 546 |
translated_text, message_text = Translators(model_name, sl, tl, input_text).quickmt()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 547 |
|
| 548 |
except Exception as error:
|
| 549 |
translated_text = error
|
|
|
|
| 20 |
langs = {iso[0]: iso[1] for iso in non_empty_isos} # {'Romanian': 'ro', 'German': 'de'}
|
| 21 |
|
| 22 |
|
| 23 |
+
models = ["Helsinki-NLP", "QUICKMT", "Argos", "Google", "HPLT", "t5-base", "t5-small", "t5-large",
|
| 24 |
+
"utter-project/EuroLLM-1.7B", "utter-project/EuroLLM-1.7B-Instruct",
|
| 25 |
+
"Unbabel/Tower-Plus-2B", "Unbabel/TowerInstruct-7B-v0.2", "Unbabel/TowerInstruct-Mistral-7B-v0.2",
|
| 26 |
+
"HuggingFaceTB/SmolLM3-3B", "winninghealth/WiNGPT-Babel-2", "tencent/Hunyuan-MT-7B",
|
| 27 |
+
"openGPT-X/Teuken-7B-instruct-commercial-v0.4", "openGPT-X/Teuken-7B-instruct-v0.6"]
|
| 28 |
allmodels = ["Helsinki-NLP",
|
| 29 |
"Helsinki-NLP/opus-mt-tc-bible-big-mul-mul", "Helsinki-NLP/opus-mt-tc-bible-big-mul-deu_eng_nld",
|
| 30 |
"Helsinki-NLP/opus-mt-tc-bible-big-mul-deu_eng_fra_por_spa", "Helsinki-NLP/opus-mt-tc-bible-big-deu_eng_fra_por_spa-mul",
|
|
|
|
| 37 |
"t5-small", "t5-base", "t5-large",
|
| 38 |
"google/flan-t5-small", "google/flan-t5-base", "google/flan-t5-large", "google/flan-t5-xl",
|
| 39 |
"google/madlad400-3b-mt", "jbochi/madlad400-3b-mt",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
]
|
| 41 |
class Translators:
|
| 42 |
def __init__(self, model_name: str, sl: str, tl: str, input_text: str):
|
|
|
|
| 113 |
message = f"Available models: {', '.join(quickmt_models)}"
|
| 114 |
return translation, message
|
| 115 |
|
| 116 |
+
@staticmethod
|
| 117 |
+
def download_argos_model(from_code, to_code):
|
| 118 |
import argostranslate.package
|
| 119 |
print('Downloading model', from_code, to_code)
|
| 120 |
# Download and install Argos Translate package
|
|
|
|
| 137 |
except Exception as error:
|
| 138 |
translated_text = error
|
| 139 |
return translated_text
|
| 140 |
+
|
| 141 |
+
def hunyuan(self):
|
| 142 |
+
pipe = pipeline("translation", model=self.model_name, device=self.device)
|
| 143 |
+
translated_text = pipe(self.input_text, src_lang=self.sl, tgt_lang=self.tl)
|
| 144 |
+
return translation
|
| 145 |
+
|
| 146 |
def HelsinkiNLP_mulroa(self):
|
| 147 |
try:
|
| 148 |
pipe = pipeline("translation", model=self.model_name, device=self.device)
|
|
|
|
| 547 |
|
| 548 |
elif model_name == "QUICKMT":
|
| 549 |
translated_text, message_text = Translators(model_name, sl, tl, input_text).quickmt()
|
| 550 |
+
|
| 551 |
+
elif "Hunyuan" in model_name:
|
| 552 |
+
translated_text = Translators(model_name, s_language, t_language, input_text).hunyuan()
|
| 553 |
+
|
| 554 |
|
| 555 |
except Exception as error:
|
| 556 |
translated_text = error
|