File size: 909 Bytes
cf6e2ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from transformers import pipeline

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

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

# Create the Gradio interface
iface = gr.Interface(
    fn=summarize_text,
    inputs=[
        gr.Textbox(label="Enter Text", placeholder="Paste your long text here...", lines=10),
        gr.Slider(minimum=10, maximum=50, label="Minimum Summary Length (tokens)", value=10),
        gr.Slider(minimum=50, maximum=150, label="Maximum Summary Length (tokens)", value=100)
    ],
    outputs=gr.Textbox(label="Summarized Text"),
    title="Text Summarizer",
    description="Enter a long piece of text to get a concise summary."
)

# Launch the interface
iface.launch()