Spaces:
Runtime error
Runtime error
File size: 1,183 Bytes
39fb067 |
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 32 33 34 35 36 37 38 |
import gradio as gr
from transformers import pipeline
def summarize_text(input_text):
"""
Function to summarize the input text using a Hugging Face transformers pipeline.
Args:
input_text (str): Text to be summarized.
Returns:
str: Summarized text.
"""
# Load the summarization pipeline using a specific model from Hugging Face
summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
# Summarize the text
summary = summarizer(input_text, max_length=130, min_length=30, do_sample=False)
# Extract and return the summarized text
return summary[0]['summary_text']
def main():
"""
Main function to launch the Gradio interface.
"""
# Define the Gradio interface
interface = gr.Interface(
fn=summarize_text,
inputs=gr.Textbox(lines=10, placeholder="Enter text here to summarize..."),
outputs="text",
title="Text Summarizer",
description="A simple text summarization app using Hugging Face's transformers. Enter your text and get a summarized version instantly!"
)
# Launch the app
interface.launch()
if __name__ == "__main__":
main()
|