task11 / app.py
renad0's picture
Create app.py
04147f4 verified
raw
history blame contribute delete
700 Bytes
import gradio as gr
from transformers import pipeline
# Load the BART model for summarization
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
# Function to summarize the input text
def summarize_text(text):
summary = summarizer(text, min_length=10, max_length=100)
return summary[0]['summary_text']
# Create the Gradio interface
iface = gr.Interface(
fn=summarize_text,
inputs=gr.Textbox(label="Enter long text here", lines=10, placeholder="Enter a long text to summarize..."),
outputs=gr.Textbox(label="Summarized text"),
live=False,
description="Text summarization application using the BART model"
)
# Launch the application
iface.launch()