shahad-b commited on
Commit
cf6e2ae
·
verified ·
1 Parent(s): f72001c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the summarization model
5
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
6
+
7
+ def summarize_text(text, min_length, max_length):
8
+ summary = summarizer(text, min_length=min_length, max_length=max_length, do_sample=False)
9
+ return summary[0]['summary_text']
10
+
11
+ # Create the Gradio interface
12
+ iface = gr.Interface(
13
+ fn=summarize_text,
14
+ inputs=[
15
+ gr.Textbox(label="Enter Text", placeholder="Paste your long text here...", lines=10),
16
+ gr.Slider(minimum=10, maximum=50, label="Minimum Summary Length (tokens)", value=10),
17
+ gr.Slider(minimum=50, maximum=150, label="Maximum Summary Length (tokens)", value=100)
18
+ ],
19
+ outputs=gr.Textbox(label="Summarized Text"),
20
+ title="Text Summarizer",
21
+ description="Enter a long piece of text to get a concise summary."
22
+ )
23
+
24
+ # Launch the interface
25
+ iface.launch()