Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,26 +1,34 @@
|
|
| 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 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
# Ejecutar la interfaz
|
| 22 |
def main():
|
| 23 |
-
|
| 24 |
|
| 25 |
if __name__ == "__main__":
|
| 26 |
-
main()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
|
|
|
| 4 |
summarizer = pipeline("summarization")
|
| 5 |
|
| 6 |
def summarize_text(text):
|
| 7 |
summary = summarizer(text, max_length=130, min_length=30, do_sample=False)
|
| 8 |
return summary[0]['summary_text']
|
| 9 |
|
| 10 |
+
with gr.Blocks() as demo:
|
| 11 |
+
gr.Markdown("""
|
| 12 |
+
Esta aplicación genera resúmenes automáticos de textos largos utilizando inteligencia artificial.
|
| 13 |
+
Solo introduce un texto y el modelo producirá un resumen conciso y claro.
|
| 14 |
+
""")
|
| 15 |
+
|
| 16 |
+
gr.Interface(
|
| 17 |
+
fn=summarize_text,
|
| 18 |
+
inputs=gr.Textbox(lines=10, placeholder="Introduce el texto aquí..."),
|
| 19 |
+
outputs=gr.Textbox(label="Resumen"),
|
| 20 |
+
allow_flagging="never"
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
gr.Markdown("""
|
| 24 |
+
---
|
| 25 |
+
Demostración de generación de resúmenes usando un modelo de aprendizaje automático.
|
| 26 |
+
|
| 27 |
+
Desarrollado con ❤️ por [@srjosueaaron](https://www.instagram.com/srjosueaaron/).
|
| 28 |
+
""")
|
| 29 |
|
|
|
|
| 30 |
def main():
|
| 31 |
+
demo.launch()
|
| 32 |
|
| 33 |
if __name__ == "__main__":
|
| 34 |
+
main()
|