Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -99,11 +99,11 @@ class Translators:
|
|
| 99 |
pipe = pipeline("translation", model=hplt_model, device=self.device)
|
| 100 |
translation = pipe(self.input_text)
|
| 101 |
translated_text = translation[0]['translation_text']
|
| 102 |
-
|
| 103 |
else:
|
| 104 |
translated_text = f'HPLT model from {iso1_to_name[self.sl]} to {iso1_to_name[self.tl]} not available!'
|
| 105 |
-
|
| 106 |
-
return translated_text,
|
| 107 |
|
| 108 |
@staticmethod
|
| 109 |
def download_argos_model(from_code, to_code):
|
|
@@ -539,9 +539,9 @@ def translate_text(input_text: str, s_language: str, t_language: str, model_name
|
|
| 539 |
|
| 540 |
elif "HPLT" in model_name:
|
| 541 |
if model_name == "HPLT-OPUS":
|
| 542 |
-
translated_text,
|
| 543 |
else:
|
| 544 |
-
translated_text,
|
| 545 |
|
| 546 |
elif model_name == "Bergamot":
|
| 547 |
translated_text, message_text = Translators(model_name, s_language, t_language, input_text).bergamot()
|
|
@@ -567,7 +567,9 @@ def get_info(model_name: str, sl: str = None, tl: str = None):
|
|
| 567 |
elif model_name == "Argos":
|
| 568 |
return httpx.get(f'https://huggingface.co/TiberiuCristianLeon/Argostranslate/raw/main/README.md').text
|
| 569 |
elif "HPLT" in model_name:
|
| 570 |
-
return '[HPLT Uni direction translation models](https://huggingface.co/collections/HPLT/hplt-12-uni-direction-translation-models)'
|
|
|
|
|
|
|
| 571 |
elif model_name == "Google":
|
| 572 |
return "Google Translate Online"
|
| 573 |
else:
|
|
|
|
| 99 |
pipe = pipeline("translation", model=hplt_model, device=self.device)
|
| 100 |
translation = pipe(self.input_text)
|
| 101 |
translated_text = translation[0]['translation_text']
|
| 102 |
+
message_text = f'Translated from {iso1_to_name[self.sl]} to {iso1_to_name[self.tl]} with {hplt_model}.'
|
| 103 |
else:
|
| 104 |
translated_text = f'HPLT model from {iso1_to_name[self.sl]} to {iso1_to_name[self.tl]} not available!'
|
| 105 |
+
message_text = f"Available models: {', '.join(hplt_models)}"
|
| 106 |
+
return translated_text, message_text
|
| 107 |
|
| 108 |
@staticmethod
|
| 109 |
def download_argos_model(from_code, to_code):
|
|
|
|
| 539 |
|
| 540 |
elif "HPLT" in model_name:
|
| 541 |
if model_name == "HPLT-OPUS":
|
| 542 |
+
translated_text, message_text = Translators(model_name, sl, tl, input_text).hplt(opus = True)
|
| 543 |
else:
|
| 544 |
+
translated_text, message_text = Translators(model_name, sl, tl, input_text).hplt()
|
| 545 |
|
| 546 |
elif model_name == "Bergamot":
|
| 547 |
translated_text, message_text = Translators(model_name, s_language, t_language, input_text).bergamot()
|
|
|
|
| 567 |
elif model_name == "Argos":
|
| 568 |
return httpx.get(f'https://huggingface.co/TiberiuCristianLeon/Argostranslate/raw/main/README.md').text
|
| 569 |
elif "HPLT" in model_name:
|
| 570 |
+
return '[HPLT Uni direction translation models](https://huggingface.co/collections/HPLT/hplt-12-uni-direction-translation-models)'
|
| 571 |
+
elif "QUICKMT" in model_name:
|
| 572 |
+
return '[QUICKMT](https://huggingface.co/quickmt)'
|
| 573 |
elif model_name == "Google":
|
| 574 |
return "Google Translate Online"
|
| 575 |
else:
|