Sunder34m2010 commited on
Commit
6957c19
·
verified ·
1 Parent(s): 889e493

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load summarization pipeline
5
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
6
+
7
+ # Function to summarize text
8
+ def summarize_text(text):
9
+ summary = summarizer(text, max_length=130, min_length=30, do_sample=False)
10
+ return summary[0]['summary_text']
11
+
12
+ # Gradio interface
13
+ interface = gr.Interface(
14
+ fn=summarize_text,
15
+ inputs=gr.Textbox(lines=10, placeholder="Paste your long text here...", label="Input Text"),
16
+ outputs=gr.Textbox(label="Summary"),
17
+ title="📝 Text Summarizer",
18
+ description="Summarize long articles using a pre-trained BART model from Hugging Face."
19
+ )
20
+
21
+ interface.launch()