juancamval commited on
Commit
da1ed8a
verified
1 Parent(s): d5693d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -1,8 +1,7 @@
1
  from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
2
  import gradio as gr
3
 
4
- tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-en-es")
5
- model = AutoModelForSeq2SeqLM.from_pretrained("Helsinki-NLP/opus-mt-en-es")
6
 
7
  def traducir_texto(texto_en):
8
  """
@@ -15,7 +14,7 @@ def traducir_texto(texto_en):
15
  str: El texto traducido al espa帽ol.
16
  """
17
  try:
18
- resultado = modelo_traduccion(texto_en)
19
  return resultado[0]['translation_text']
20
  except Exception as e:
21
  return f"Error en la traducci贸n: {e}"
 
1
  from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
2
  import gradio as gr
3
 
4
+ pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es")
 
5
 
6
  def traducir_texto(texto_en):
7
  """
 
14
  str: El texto traducido al espa帽ol.
15
  """
16
  try:
17
+ resultado = pipe(texto_en)
18
  return resultado[0]['translation_text']
19
  except Exception as e:
20
  return f"Error en la traducci贸n: {e}"