File size: 609 Bytes
bfa768d
12b9f99
bfa768d
12b9f99
bfa768d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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()