Didier commited on
Commit
4661832
1 Parent(s): 5d580b9

Using smaller m2m100 model

Browse files
Files changed (2) hide show
  1. app.py +3 -3
  2. model_translation.py +1 -1
app.py CHANGED
@@ -18,6 +18,7 @@ from deep_translator import GoogleTranslator
18
  from model_spacy import nlp_xx
19
 
20
  import model_translation
 
21
 
22
 
23
  def translate_with_Helsinki(
@@ -72,7 +73,6 @@ def translate_text(
72
  tgt_lang = 'en'
73
 
74
  # translate
75
- m2m100 = model_translation.ModelM2M100()
76
  translated_text_m2m100 = m2m100.translate(text, src_lang, tgt_lang)
77
  translated_text_google_translate = GoogleTranslator(
78
  source='auto', target='en').translate(text=text)
@@ -102,7 +102,7 @@ with gr.Blocks() as demo:
102
  # Output
103
  output_text_m2m100 = gr.Textbox(
104
  lines=4,
105
- label="Facebook m2m100 (1.2B)",
106
  render=True
107
  )
108
  output_text_google_translate = gr.Textbox(
@@ -136,7 +136,7 @@ with gr.Blocks() as demo:
136
 
137
  with gr.Accordion("Documentation", open=False):
138
  gr.Markdown("""
139
- - Models: serving Facebook M2M100 and Google Translate.
140
  """)
141
 
142
  if __name__ == "__main__":
 
18
  from model_spacy import nlp_xx
19
 
20
  import model_translation
21
+ m2m100 = model_translation.ModelM2M100()
22
 
23
 
24
  def translate_with_Helsinki(
 
73
  tgt_lang = 'en'
74
 
75
  # translate
 
76
  translated_text_m2m100 = m2m100.translate(text, src_lang, tgt_lang)
77
  translated_text_google_translate = GoogleTranslator(
78
  source='auto', target='en').translate(text=text)
 
102
  # Output
103
  output_text_m2m100 = gr.Textbox(
104
  lines=4,
105
+ label="Facebook m2m100 (418M)",
106
  render=True
107
  )
108
  output_text_google_translate = gr.Textbox(
 
136
 
137
  with gr.Accordion("Documentation", open=False):
138
  gr.Markdown("""
139
+ - Models: serving Facebook M2M100 (418M) and Google Translate.
140
  """)
141
 
142
  if __name__ == "__main__":
model_translation.py CHANGED
@@ -203,7 +203,7 @@ class ModelM2M100(metaclass=Singleton):
203
  Model: https://huggingface.co/facebook/m2m100_1.2B
204
  """
205
  def __init__(self):
206
- self._model_name = "facebook/m2m100_1.2B"
207
  self._tokenizer = M2M100Tokenizer.from_pretrained(self._model_name)
208
  self._model = M2M100ForConditionalGeneration.from_pretrained(
209
  self._model_name,
 
203
  Model: https://huggingface.co/facebook/m2m100_1.2B
204
  """
205
  def __init__(self):
206
+ self._model_name = "facebook/m2m100_418M"
207
  self._tokenizer = M2M100Tokenizer.from_pretrained(self._model_name)
208
  self._model = M2M100ForConditionalGeneration.from_pretrained(
209
  self._model_name,