bart-summarizer / app.py
abdull4h's picture
Create app.py
6838503 verified
raw
history blame contribute delete
836 Bytes
import gradio as gr
from transformers import pipeline
# Initialize the summarization pipeline with facebook/bart-large-cnn
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
def summarize_text(text):
# Generate summary with a minimum of 10 tokens and a maximum of 100 tokens
summary = summarizer(text, min_length=10, max_length=100)
return summary[0]['summary_text']
# Create the Gradio interface
demo = gr.Interface(
fn=summarize_text,
inputs=gr.Textbox(
lines=10,
placeholder="Enter a long piece of text here...",
label="Input Text"
),
outputs=gr.Textbox(label="Summary"),
title="BART Text Summarizer",
description="Enter a long piece of text and get a concise summary using facebook/bart-large-cnn."
)
if __name__ == "__main__":
demo.launch()