File size: 684 Bytes
79b51ce
 
 
 
 
 
 
 
 
 
 
 
 
6df6b52
 
79b51ce
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gradio as gr
from transformers import pipeline

# Load the Hugging Face pre-trained summarization model
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")

# Define the function for text summarization
def summarize_text(input_text):
    # Get the summary from the model
    summary = summarizer(input_text, max_length=150, min_length=50, do_sample=False)
    return summary[0]['summary_text']

# Create the Gradio interface
interface = gr.Interface(fn=summarize_text, inputs="text", outputs="text", title="Text Summarization App", 
                         description="Enter a long text to get a summarized version.")

# Launch the app
interface.launch()