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

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

def summarize_text(text):
    summary = summarizer(text, max_length=150, min_length=50, do_sample=False)
    return summary[0]['summary_text']

# Create a Gradio Interface
iface = gr.Interface(
    fn=summarize_text,
    inputs=gr.Textbox(lines=5, placeholder="Enter text to summarize"),
    outputs="text",
    title="AI Summarizer",
    description="Enter a long paragraph, and the AI will summarize it for you.",
)

# Launch the app
if __name__ == "__main__":
    iface.launch()