File size: 924 Bytes
7ccffdd
 
 
 
8302077
 
7ccffdd
 
8302077
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
28
# from transformers import pipeline

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

summarizer = pipeline("summarization", model="facebook/bart-large-cnn", framework="pt")


def summarize_text(input_text):
    # Perform summarization
    summary = summarizer(input_text, max_length=130, min_length=30, do_sample=False)
    return summary[0]['summary_text']

import gradio as gr

# Define Gradio interface
interface = gr.Interface(
    fn=summarize_text,             # Function to summarize
    inputs=gr.Textbox(lines=10, placeholder="Enter text to summarize..."),  # Input box
    outputs="text",                # Output box
    title="Text Summarizer",       # App title
    description="Paste a long paragraph or article, and this app will summarize it into a concise version."
)

# Launch the interface
interface.launch()