| import gradio as gr |
| from transformers import pipeline |
|
|
| summarizer = pipeline( |
| "summarization", |
| model="facebook/bart-large-cnn" |
| ) |
|
|
| def summarize_text(text): |
|
|
| result = summarizer( |
| text, |
| max_length=200, |
| min_length=40, |
| do_sample=False |
| ) |
|
|
| return result[0]["summary_text"] |
|
|
| app = gr.Interface( |
| fn=summarize_text, |
|
|
| inputs=gr.Textbox( |
| lines=20, |
| label="Input Text" |
| ), |
|
|
| outputs=gr.Textbox( |
| lines=10, |
| label="Generated Summary" |
| ), |
|
|
| title="📚AI Text Summarizer", |
| description="""Generate concise summaries using Hugging Face Transformers. |
| Built with Gradio and BART-Large-CNN.""" |
| ) |
|
|
| app.launch() |