File size: 691 Bytes
b80349f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from transformers import pipeline
import gradio as gr

# Load the summarizer model
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")

# Define the function for Gradio to use
def summarize_article(text):
    summary = summarizer(text, max_length=130, min_length=30, do_sample=False)
    return summary[0]['summary_text']

# Gradio interface
iface = gr.Interface(
    fn=summarize_article,
    inputs=gr.Textbox(lines=20, label="Enter News Article 📄"),
    outputs=gr.Textbox(label="Summary ✨"),
    title="Article Summarizer 📰",
    description="Paste your article and get a short summary! Powered by facebook/bart-large-cnn."
)

# Launch the app
iface.launch()