LAP-DEV commited on
Commit
80b98d7
·
verified ·
1 Parent(s): 2471f8c

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
- self.cache_parameters(model_size=model_size,src_lang=src_lang,tgt_lang=tgt_lang,max_length=max_length,add_timestamp=add_timestamp)
175
- self.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 = self.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
- self.release_cuda_memory()
189
 
190
  @staticmethod
191
  def get_device():
 
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
  except Exception as e:
186
  print(f"Error: {str(e)}")
187
  finally:
188
+ release_cuda_memory()
189
 
190
  @staticmethod
191
  def get_device():