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

# Initialize the summarization pipeline with a specified model
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")

def summarize_text(input_text):
    """Function to summarize the input text."""
    summary_result = text_summary(input_text)
    return summary_result[0]['summary_text']

# Close any existing Gradio interfaces
gr.close_all()

# Define a Gradio interface for the summarization function
demo = gr.Interface(
    fn=summarize_text,
    inputs=gr.Textbox(label="Input text to summarize", lines=10, placeholder="Enter your text here..."),
    outputs=gr.Textbox(label="Summarized text", lines=4),
    title="Text Summarizer",
    description="This application summarizes text. Just paste your text and get a summary!"
)

# Launch the Gradio interface
demo.launch()