Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,26 @@
|
|
1 |
-
from transformers import pipeline
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
-
|
|
|
5 |
|
6 |
-
def
|
7 |
-
summary = summarizer(text, max_length=
|
8 |
return summary[0]['summary_text']
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
""
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
inputs=gr.Textbox(label="Introduce el texto largo", placeholder="Escribe o pega un texto aquí..."),
|
20 |
-
outputs=gr.Textbox(label="Resumen"),
|
21 |
-
)
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
Desarrollado con ❤️ por [@srjosueaaron](https://www.instagram.com/srjosueaaron/).
|
28 |
-
""")
|
29 |
|
30 |
if __name__ == "__main__":
|
31 |
-
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Cargar el pipeline de resumen
|
5 |
+
summarizer = pipeline("summarization")
|
6 |
|
7 |
+
def summarize_text(text):
|
8 |
+
summary = summarizer(text, max_length=130, min_length=30, do_sample=False)
|
9 |
return summary[0]['summary_text']
|
10 |
|
11 |
+
# Crear la interfaz con Gradio
|
12 |
+
iface = gr.Interface(
|
13 |
+
fn=summarize_text,
|
14 |
+
inputs=gr.Textbox(lines=10, placeholder="Introduce el texto aquí..."),
|
15 |
+
outputs=gr.Textbox(label="Resumen"),
|
16 |
+
title="Generador de Resúmenes",
|
17 |
+
description="Introduce un texto y obtendrás un resumen generado automáticamente.",
|
18 |
+
allow_flagging="never"
|
19 |
+
)
|
|
|
|
|
|
|
20 |
|
21 |
+
# Ejecutar la interfaz
|
22 |
+
def main():
|
23 |
+
iface.launch()
|
|
|
|
|
|
|
24 |
|
25 |
if __name__ == "__main__":
|
26 |
+
main()
|