Spaces:
Build error
Build error
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the summarization model | |
| summarizer = pipeline("summarization", model="facebook/bart-large-cnn") | |
| # Define the function to summarize text | |
| def summarize_text(text): | |
| if not text.strip(): | |
| return "Please enter some text to summarize." | |
| summary = summarizer(text, max_length=150, min_length=30, do_sample=False) | |
| return summary[0]["summary_text"] | |
| # Create the Gradio interface | |
| iface = gr.Interface( | |
| fn=summarize_text, | |
| inputs=gr.Textbox(lines=10, placeholder="Enter text to summarize..."), | |
| outputs="text", | |
| title="Text Summarization Chatbot", | |
| description="Enter a long text passage, and the chatbot will summarize it for you using the 'facebook/bart-large-cnn' model.", | |
| theme="compact" | |
| ) | |
| # Launch the app | |
| iface.launch() |