Text_Summarize / app.py
anky2002's picture
initial
b9fdd3d
raw
history blame
861 Bytes
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()