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