Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
# Initialize the summarization pipeline with a specified model | |
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") | |
def summarize_text(input_text): | |
"""Function to summarize the input text.""" | |
summary_result = text_summary(input_text) | |
return summary_result[0]['summary_text'] | |
# Close any existing Gradio interfaces | |
gr.close_all() | |
# Define a Gradio interface for the summarization function | |
demo = gr.Interface( | |
fn=summarize_text, | |
inputs=gr.Textbox(label="Input text to summarize", lines=10, placeholder="Enter your text here..."), | |
outputs=gr.Textbox(label="Summarized text", lines=4), | |
title="Text Summarizer", | |
description="This application summarizes text. Just paste your text and get a summary!" | |
) | |
# Launch the Gradio interface | |
demo.launch() | |