# app.py | |
import gradio as gr | |
from transformers import pipeline | |
# Choose model (either one of the two below) | |
model_name = "Falconsai/text_summarization" # or "facebook/bart-large-cnn" | |
summarizer = pipeline("summarization", model=model_name) | |
def summarize(text): | |
summary = summarizer(text, max_length=150, min_length=30, do_sample=False) | |
return summary[0]["summary_text"] | |
iface = gr.Interface( | |
fn=summarize, | |
inputs=gr.Textbox(lines=10, placeholder="Enter long text here..."), | |
outputs=gr.Textbox(label="Summary"), | |
allow_flagging="never", | |
title="Text Summarizer" | |
) | |
iface.launch() | |