| import gradio as gr
|
| from transformers import pipeline
|
|
|
|
|
| summarizer = pipeline(
|
| "summarization",
|
| model="facebook/bart-large-cnn"
|
| )
|
|
|
|
|
| def summarize_text(text):
|
| if len(text.strip()) == 0:
|
| return "Please enter some text."
|
|
|
| result = summarizer(
|
| text,
|
| max_length=120,
|
| min_length=30,
|
| do_sample=False
|
| )
|
|
|
| return result[0]["summary_text"]
|
|
|
|
|
| interface = gr.Interface(
|
| fn=summarize_text,
|
| inputs=gr.Textbox(
|
| lines=15,
|
| placeholder="Paste article here..."
|
| ),
|
| outputs="text",
|
| title="Article Summarizer",
|
| description="Summarize long articles using BART"
|
| )
|
|
|
| interface.launch(share=True) |