Spaces:
Sleeping
Sleeping
File size: 962 Bytes
7c99478 374e2fd 4524c25 374e2fd 083ef6a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import gradio as gr
from transformers import pipeline
# Initialize the summarization pipeline
model_name = "sshleifer/distilbart-cnn-12-6"
summarizer = pipeline("summarization", model=model_name)
def generate_summary(text):
summary_text = summarizer(text, max_length=130, min_length=30, do_sample=False)
return summary_text[0]['summary_text']
# Create a Gradio interface with custom labels
interface = gr.Interface(fn=generate_summary,
inputs=gr.Textbox(lines=10,
placeholder="Enter Text Here...",
label="Input Text for Summarization"),
outputs=gr.Textbox(label="Summarized Text"),
title="Text Summarization",
description="Enter a block of text to generate a concise summary using a Transformers model")
# Launch the interface
interface.launch()
|