Spaces:
Build error
Build error
| from transformers import pipeline | |
| import gradio as gr | |
| # Initialize the summarizer pipeline | |
| summarizer = pipeline("summarization", model="t5-base", tokenizer="t5-small", truncation=True, framework="tf") | |
| def summarize(text): | |
| # Replace HTML entities | |
| text = text.replace('"', '"') | |
| text = text.replace(''', "'") | |
| text = text.replace('&', "&") | |
| # Summarize the text | |
| result = summarizer(text, min_length=100, truncation=True) | |
| return result[0]["summary_text"] | |
| # Define the Gradio interface | |
| iface = gr.Interface( | |
| fn=summarize, | |
| inputs=gr.Textbox(lines=10, placeholder="Enter text to summarize..."), | |
| outputs="text" | |
| ) | |
| # Launch the Gradio interface | |
| iface.launch() | |