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

# Initialize the model
model = pipeline("summarization", model="luisotorres/bart-finetuned-samsum")

def summarize_text(text):
    try:
        summary = model(text, max_length=130, min_length=30)
        return summary[0]["summary_text"]
    except Exception as e:
        return str(e)

# Create Gradio interface
iface = gr.Interface(
    fn=summarize_text,
    inputs=gr.Textbox(label="Input Text", lines=5),
    outputs=gr.Textbox(label="Summary"),
    title="Text Summarization",
    description="Enter your text to generate a summary.",
    examples=[
        ["Sarah: Do you think it's a good idea to invest in Bitcoin?\nEmily: I'm skeptical. The market is very volatile, and you could lose money.\nSarah: True. But there's also a high upside, right?"]
    ]
)

# Launch the interface
iface.launch()