Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Initialize the summarization pipeline | |
| model_name = "sshleifer/distilbart-cnn-12-6" | |
| summarizer = pipeline("summarization", model=model_name) | |
| def generate_summary(text): | |
| summary_text = summarizer(text, max_length=130, min_length=30, do_sample=False) | |
| return summary_text[0]['summary_text'] | |
| # Create a Gradio interface with custom labels | |
| interface = gr.Interface(fn=generate_summary, | |
| inputs=gr.Textbox(lines=10, | |
| placeholder="Enter Text Here...", | |
| label="Input Text for Summarization"), | |
| outputs=gr.Textbox(label="Summarized Text"), | |
| title="Text Summarization", | |
| description="Enter a block of text to generate a concise summary using a Transformers model") | |
| # Launch the interface | |
| interface.launch() | |