Spaces:
Sleeping
Sleeping
File size: 792 Bytes
853a5c8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from transformers import pipeline
import gradio as gr
# Load the summarization model once
model = pipeline("summarization")
# Prediction function
def predict(prompt):
try:
# Generate summary and return
summary = model(prompt, max_length=150, min_length=30, do_sample=False)[0][
"summary_text"
]
return summary
except Exception as e:
return f"Error: {str(e)}"
# Gradio interface
with gr.Interface(
fn=predict,
inputs=gr.Textbox(
label="Enter text to summarize", placeholder="Type your content here..."
),
outputs=gr.Textbox(label="Summary"),
title="Text Summarizer",
description="Enter text and get a concise summary powered by Hugging Face transformers.",
) as interface:
interface.launch()
|