File size: 722 Bytes
542de0c 29ce124 542de0c 29ce124 542de0c 29ce124 bdaf3dd 29ce124 bdaf3dd 29ce124 bdaf3dd 29ce124 bdaf3dd 29ce124 d484432 bdaf3dd 29ce124 542de0c 29ce124 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import gradio as gr
from transformers import pipeline
# Load lightweight summarization model
summarizer = pipeline(
"summarization",
model="sshleifer/distilbart-cnn-12-6",
device=-1
)
def summarize(text):
if not text or not text.strip():
return "Please enter some text."
text = text[:4000]
result = summarizer(
text,
max_length=150,
min_length=40,
do_sample=False
)
return result[0]["summary_text"]
app = gr.Interface(
fn=summarize,
inputs=gr.Textbox(lines=10, label="Paste text here"),
outputs=gr.Textbox(label="Summary"),
title="AI Text Summarizer",
description="Simple AI-powered text summarization tool"
)
app.launch()
|