Update modules/translation/translation_base.py
Browse files
modules/translation/translation_base.py
CHANGED
|
@@ -171,13 +171,13 @@ class TranslationBase(ABC):
|
|
| 171 |
List[dict] with translation
|
| 172 |
"""
|
| 173 |
try:
|
| 174 |
-
cache_parameters(model_size=model_size,src_lang=src_lang,tgt_lang=tgt_lang,max_length=max_length,add_timestamp=add_timestamp)
|
| 175 |
-
update_model(model_size=model_size,src_lang=src_lang,tgt_lang=tgt_lang,progress=progress)
|
| 176 |
|
| 177 |
total_progress = len(input_list_dict)
|
| 178 |
for index, dic in enumerate(input_list_dict):
|
| 179 |
progress(index / total_progress, desc="Translating..")
|
| 180 |
-
translated_text = translate(dic["text"], max_length=max_length)
|
| 181 |
dic["text"] = translated_text
|
| 182 |
|
| 183 |
return input_list_dict
|
|
@@ -185,7 +185,7 @@ class TranslationBase(ABC):
|
|
| 185 |
except Exception as e:
|
| 186 |
print(f"Error: {str(e)}")
|
| 187 |
finally:
|
| 188 |
-
release_cuda_memory()
|
| 189 |
|
| 190 |
@staticmethod
|
| 191 |
def get_device():
|
|
|
|
| 171 |
List[dict] with translation
|
| 172 |
"""
|
| 173 |
try:
|
| 174 |
+
TranslationBase.cache_parameters(model_size=model_size,src_lang=src_lang,tgt_lang=tgt_lang,max_length=max_length,add_timestamp=add_timestamp)
|
| 175 |
+
TranslationBase.update_model(model_size=model_size,src_lang=src_lang,tgt_lang=tgt_lang,progress=progress)
|
| 176 |
|
| 177 |
total_progress = len(input_list_dict)
|
| 178 |
for index, dic in enumerate(input_list_dict):
|
| 179 |
progress(index / total_progress, desc="Translating..")
|
| 180 |
+
translated_text = TranslationBase.translate(dic["text"], max_length=max_length)
|
| 181 |
dic["text"] = translated_text
|
| 182 |
|
| 183 |
return input_list_dict
|
|
|
|
| 185 |
except Exception as e:
|
| 186 |
print(f"Error: {str(e)}")
|
| 187 |
finally:
|
| 188 |
+
TranslationBase.release_cuda_memory()
|
| 189 |
|
| 190 |
@staticmethod
|
| 191 |
def get_device():
|