Spaces:
Sleeping
Sleeping
import torch | |
import gradio as gr | |
# Use a pipeline as a high-level helper | |
from transformers import pipeline | |
# Initialize the summarization pipeline | |
pipe = pipeline("summarization", model="Falconsai/text_summarization") | |
# Define the summarize function | |
def summarize(input): | |
output = pipe(input) | |
return output[0]['summary_text'] | |
# Define the Gradio interface | |
iface = gr.Interface( | |
fn=summarize, | |
inputs=gr.Textbox(lines=12, placeholder="Enter text to summarize here..."), | |
outputs="text", | |
title="Text Summarizer", | |
description="Enter a long piece of text, and the summarizer will provide a concise summary." | |
) | |
# Launch the interface | |
if __name__ == "__main__": | |
iface.launch() | |