Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| pip install transformers | |
| from transformers import pipeline | |
| # Load the summarization pipeline | |
| summarizer = pipeline("summarization", model="t5-small", tokenizer="t5-small") | |
| # Function for text summarization | |
| def summarize_text(text): | |
| if text: | |
| summary = summarizer(text, max_length=150, min_length=30, do_sample=False) | |
| return summary[0]['summary_text'] | |
| return "Please enter text to summarize." | |
| # Create a Gradio interface | |
| iface = gr.Interface( | |
| fn=summarize_text, | |
| inputs=gr.inputs.Textbox(lines=10, label="Enter text to summarize"), | |
| outputs=gr.outputs.Textbox(label="Summary"), | |
| title="Text Summarization", | |
| description="Use the model to summarize text." | |
| ) | |
| # Launch the Gradio interface | |
| iface.launch() | |