Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
# Step 3: Define the summarization function | |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn") | |
def summarize(text): | |
summary = summarizer(text, max_length=150, min_length=40, do_sample=False) | |
return summary[0]['summary_text'] | |
# Step 4: Create the Gradio interface | |
iface = gr.Interface( | |
fn=summarize, | |
inputs="textbox", | |
outputs="textbox", | |
title="Text Summarizer", | |
description="Summarize text using the facebook/bart-large-cnn model from Hugging Face" | |
) | |
# Step 5: Launch the interface | |
iface.launch() |