File size: 764 Bytes
773d3a5
654cc18
 
773d3a5
654cc18
 
773d3a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from transformers import pipeline

# Load the summarization model
pipe = pipeline("summarization", model="Falconsai/text_summarization")

# Define the function to summarize text
def summarize_text(text):
    if not text.strip():
        return "Please enter some text to summarize."
    summary = pipe(text, max_length=150, min_length=30, do_sample=False)
    return summary[0]['summary_text']

# Create Gradio interface
iface = gr.Interface(
    fn=summarize_text,
    inputs=gr.Textbox(lines=5, placeholder="Enter text to summarize..."),
    outputs="text",
    title="Text Summarization App",
    description="Enter text, and the AI will generate a concise summary.",
)

# Launch the Gradio app
if __name__ == "__main__":
    iface.launch()