Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load summarizer pipeline (T5 model, lightweight)
|
| 5 |
+
summarizer = pipeline("summarization", model="t5-small")
|
| 6 |
|
| 7 |
+
def summarize_text(text):
|
| 8 |
+
summary = summarizer(text, max_length=150, min_length=30, do_sample=False)
|
| 9 |
+
return summary[0]['summary_text']
|
| 10 |
+
|
| 11 |
+
# Gradio interface
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=summarize_text,
|
| 14 |
+
inputs=gr.Textbox(lines=8, placeholder="Paste any article or text here..."),
|
| 15 |
+
outputs=gr.Textbox(lines=8), # show full text without scrolling
|
| 16 |
+
title="AI Text Summarizer 📖✨",
|
| 17 |
+
description="Paste long text and get concise, clear summaries instantly!"
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
if __name__ == "__main__":
|
| 21 |
+
iface.launch()
|