meinvirgos commited on
Commit
7431216
·
verified ·
1 Parent(s): 142fdda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -16
app.py CHANGED
@@ -17,24 +17,24 @@ flores_codes["Galego"] = "glg_Latn"
17
 
18
  def translation(source, target, text):
19
 
20
- start_time = time.time()
21
  source = flores_codes[source]
22
  target = flores_codes[target]
23
 
24
  translator = pipeline('translation', model=model, tokenizer=tokenizer,
25
 
26
- src_lang=source, tgt_lang=target)
27
  output = translator(text, max_length=400)
28
 
29
- end_time = time.time()
30
 
31
  output = output[0]['translation_text']
32
- result = {'inference_time': end_time - start_time,
33
- 'source': source,
34
- 'target': target,
35
- 'result': output}
36
- return result
37
-
38
 
39
  if __name__ == '__main__':
40
  print('\tIniciando...')
@@ -42,20 +42,21 @@ if __name__ == '__main__':
42
 
43
  # define gradio demo
44
  lang_codes = list(flores_codes.keys())
45
- inputs = [gr.Dropdown(lang_codes, value='Castellano', label='Original'),
46
- gr.Dropdown(lang_codes, value='Asturianu', label='Traducido'),
47
- gr.Textbox(label="Input text"),
48
  ]
49
 
50
- outputs = gr.JSON()
51
 
52
  title = "Traductor Multilingüe"
53
 
54
- description = """Este traductor utiliza el siguiente modelo de lenguaje de
55
-
56
- Meta:
57
  https://github.com/facebookresearch/fairseq/tree/nllb
 
58
  Adaptado de:
 
59
  https://huggingface.co/spaces/Azwaw/Text_Translation_Multi-languages"""
60
 
61
 
 
17
 
18
  def translation(source, target, text):
19
 
20
+ #start_time = time.time()
21
  source = flores_codes[source]
22
  target = flores_codes[target]
23
 
24
  translator = pipeline('translation', model=model, tokenizer=tokenizer,
25
 
26
+ src_lang=source, tgt_lang=target)
27
  output = translator(text, max_length=400)
28
 
29
+ #end_time = time.time()
30
 
31
  output = output[0]['translation_text']
32
+ #result = {'inference_time': end_time - start_time,
33
+ # 'source': source,
34
+ # 'target': target,
35
+ # 'result': output}
36
+ #return result
37
+ return output;
38
 
39
  if __name__ == '__main__':
40
  print('\tIniciando...')
 
42
 
43
  # define gradio demo
44
  lang_codes = list(flores_codes.keys())
45
+ inputs = [gr.Dropdown(lang_codes, value='Castellano', label='Idioma original'),
46
+ gr.Dropdown(lang_codes, value='Asturianu', label='Traducir al...'),
47
+ gr.Textbox(label="Texto a traducir"),
48
  ]
49
 
50
+ outputs = [gr.Textbox(label="Texto traducido"),]
51
 
52
  title = "Traductor Multilingüe"
53
 
54
+ description = """Este traductor utiliza el siguiente modelo de lenguaje de Meta:
55
+
 
56
  https://github.com/facebookresearch/fairseq/tree/nllb
57
+
58
  Adaptado de:
59
+
60
  https://huggingface.co/spaces/Azwaw/Text_Translation_Multi-languages"""
61
 
62