Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,10 +3,10 @@ from transformers import pipeline, T5Tokenizer, T5ForConditionalGeneration
|
|
| 3 |
import requests
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
# Cargar el token de Hugging Face configurado en el
|
| 7 |
token = os.getenv("HF_TOKEN")
|
| 8 |
if not token:
|
| 9 |
-
raise ValueError("El token no se configuró correctamente en las variables de entorno
|
| 10 |
|
| 11 |
API_URL = "https://api-inference.huggingface.co/models/Helsinki-NLP/opus-mt-en-es"
|
| 12 |
headers = {"Authorization": f"Bearer {token}"}
|
|
@@ -37,10 +37,24 @@ def texto_sum(text):
|
|
| 37 |
return translation[0]['translation_text']
|
| 38 |
|
| 39 |
# Interfaz de Gradio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
demo = gr.Interface(
|
| 41 |
fn=texto_sum,
|
| 42 |
inputs=gr.Textbox(label="Texto a introducir:", placeholder="Introduce el texto a resumir aquí..."),
|
| 43 |
-
outputs="text"
|
|
|
|
|
|
|
| 44 |
)
|
|
|
|
| 45 |
# Lanzar la interfaz
|
| 46 |
demo.launch()
|
|
|
|
| 3 |
import requests
|
| 4 |
import os
|
| 5 |
|
| 6 |
+
# Cargar el token de Hugging Face configurado en el entorno
|
| 7 |
token = os.getenv("HF_TOKEN")
|
| 8 |
if not token:
|
| 9 |
+
raise ValueError("El token no se configuró correctamente en las variables de entorno.")
|
| 10 |
|
| 11 |
API_URL = "https://api-inference.huggingface.co/models/Helsinki-NLP/opus-mt-en-es"
|
| 12 |
headers = {"Authorization": f"Bearer {token}"}
|
|
|
|
| 37 |
return translation[0]['translation_text']
|
| 38 |
|
| 39 |
# Interfaz de Gradio
|
| 40 |
+
description_text = """
|
| 41 |
+
### Instrucciones para el uso de la aplicación
|
| 42 |
+
1. Introduzca el texto que desea resumir en el cuadro de texto.
|
| 43 |
+
2. La aplicación dividirá automáticamente el texto si es muy largo.
|
| 44 |
+
3. Primero, se realizará un resumen del texto introducido.
|
| 45 |
+
4. A continuación, el resumen será traducido al español.
|
| 46 |
+
5. El resultado final será un texto resumido y traducido al español.
|
| 47 |
+
|
| 48 |
+
**Nota:** El resumen y la traducción pueden tomar algunos segundos.
|
| 49 |
+
"""
|
| 50 |
+
|
| 51 |
demo = gr.Interface(
|
| 52 |
fn=texto_sum,
|
| 53 |
inputs=gr.Textbox(label="Texto a introducir:", placeholder="Introduce el texto a resumir aquí..."),
|
| 54 |
+
outputs="text",
|
| 55 |
+
title="Aplicación de Resumen y Traducción",
|
| 56 |
+
description=description_text
|
| 57 |
)
|
| 58 |
+
|
| 59 |
# Lanzar la interfaz
|
| 60 |
demo.launch()
|