File size: 833 Bytes
f3b811a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from transformers import pipeline

# Initialize the BART summarization model from Hugging Face
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")

# Define the function that will summarize the text
def summarize_text(input_text):
    summary = summarizer(input_text, max_length=150, min_length=50, do_sample=False)
    return summary[0]['summary_text']

# Create a Gradio interface
iface = gr.Interface(fn=summarize_text, 
                     inputs="text", 
                     outputs="text",
                     title="Text Summarization App",
                     description="This app summarizes long-form text (articles, papers, books) into concise key points or a paragraph.",
                     examples=[["Enter your article text here"]])

# Launch the interface
iface.launch()