File size: 718 Bytes
5cb500c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 pipeline
pipe = pipeline("summarization", model="facebook/bart-large-cnn")

# Define a function that summarizes text based on the input
def summarize_text(text):
    summary = pipe(text, max_length=150, min_length=40, do_sample=False)
    return summary[0]['summary_text']

# Set up the Gradio interface
interface = gr.Interface(
    fn=summarize_text, 
    inputs=gr.Textbox(lines=10, label="Enter text to summarize"), 
    outputs=gr.Textbox(label="Summary"),
    title="Text Summarization with BART",
    description="Enter a text block and get a summarized version using the BART model."
)

# Launch the Gradio app
interface.launch()