Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- app.py +20 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
summarizer = pipeline("summarization")
|
| 5 |
+
|
| 6 |
+
def summarize_text(text):
|
| 7 |
+
if text.strip() == "":
|
| 8 |
+
return "Please enter some text."
|
| 9 |
+
summary = summarizer(text, max_length=150, min_length=30, do_sample=False)
|
| 10 |
+
return summary[0]['summary_text']
|
| 11 |
+
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=summarize_text,
|
| 14 |
+
inputs=gr.Textbox(lines=15, placeholder="Enter your text here..."),
|
| 15 |
+
outputs="text",
|
| 16 |
+
title="📝 Smart Text Summarizer",
|
| 17 |
+
description="Paste any article or paragraph and get a short summary using AI."
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
transformers
|
| 3 |
+
torch
|