task1 / app.py
fadiyahalanazi's picture
Update app.py
a1fe418 verified
raw
history blame contribute delete
769 Bytes
import gradio as gr
from transformers import pipeline
# Load the summarization model
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
def summarize_text(text):
if len(text.strip()) == 0:
return "Please enter some text to summarize."
summary = summarizer(text, max_length=100, min_length=10, do_sample=False)
return summary[0]['summary_text']
iface = gr.Interface(
fn=summarize_text,
inputs=gr.Textbox(lines=5, placeholder="Enter a long text here...", label="Input Text"),
outputs=gr.Textbox(label="Summarized Text"),
title="Text Summarization App",
description="Enter a long piece of text and click the button to summarize it using the BART model.",
allow_flagging="never"
)
iface.launch()