abdull4h commited on
Commit
6838503
·
verified ·
1 Parent(s): 5dfbcbb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Initialize the summarization pipeline with facebook/bart-large-cnn
5
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
6
+
7
+ def summarize_text(text):
8
+ # Generate summary with a minimum of 10 tokens and a maximum of 100 tokens
9
+ summary = summarizer(text, min_length=10, max_length=100)
10
+ return summary[0]['summary_text']
11
+
12
+ # Create the Gradio interface
13
+ demo = gr.Interface(
14
+ fn=summarize_text,
15
+ inputs=gr.Textbox(
16
+ lines=10,
17
+ placeholder="Enter a long piece of text here...",
18
+ label="Input Text"
19
+ ),
20
+ outputs=gr.Textbox(label="Summary"),
21
+ title="BART Text Summarizer",
22
+ description="Enter a long piece of text and get a concise summary using facebook/bart-large-cnn."
23
+ )
24
+
25
+ if __name__ == "__main__":
26
+ demo.launch()