Spaces:
Runtime error
Runtime error
| from gradio import Textbox | |
| from transformers import pipeline | |
| import gradio as gr | |
| DESCRIPTION = ''' | |
| <div> | |
| <h1 style="text-align: center;">Summarization Chatbot</h1> | |
| <p>This Space demonstrates the Summarization model <a href="https://huggingface.co/spaces/AyeshaNoreen/chatboot-edit"><b>Text Summarization Chatbot</b></a>. Meta Llama3 is the new open LLM and comes in two sizes: 8b and 70b. Feel free to play with it, or duplicate to run privately!</p> | |
| <p>🦕 Looking for an even more powerful model? Check out the <a href="https://huggingface.co/chat/"><b>Hugging Chat</b></a> integration for facebook/bart-large-cnn</p> | |
| </div> | |
| ''' | |
| # Initialize the summarization pipeline | |
| summarization_pipe = pipeline("summarization", model="facebook/bart-large-cnn") | |
| # Function to summarize input text | |
| def summarize_text(text): | |
| summary = summarization_pipe(text, max_length=100, min_length=50, do_sample=False)[0]['summary_text'] | |
| return summary | |
| # Create the chat interface | |
| chatbot = gr.Interface( | |
| summarize_text, | |
| gr.Textbox(lines=5, label="Input Text"), | |
| gr.Textbox(label="Summary"), | |
| #title="Text Summarization Chatbot", | |
| description=DESCRIPTION, | |
| #theme="compact" | |
| ) | |
| # Launch the chat interface | |
| if __name__ == "__main__": | |
| chatbot.launch(share=True) | |