File size: 783 Bytes
8d2d044
 
ad53833
8d2d044
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import torch
# Load the summarization model
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")

def summarize_text(input_text):
    # Summarize the input text
    summary = summarizer(input_text, min_length=10, max_length=100, do_sample=False)
    return summary[0]['summary_text']

# Create the Gradio interface
interface = gr.Interface(
    fn=summarize_text,
    inputs=gr.Textbox(label="Enter Text", placeholder="Type or paste your long text here...", lines=10),
    outputs=gr.Textbox(label="Summary"),
    title="Text Summarization App",
    description="Enter a long piece of text and click the button to get a summarized version."
)

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