MK-316 commited on
Commit
083ef6a
·
verified ·
1 Parent(s): 20cc011

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
+ # Initialize the summarization pipeline
5
+ summarizer = pipeline("summarization")
6
+
7
+ def generate_summary(text):
8
+ summary_text = summarizer(text, max_length=130, min_length=30, do_sample=False)
9
+ return summary_text[0]['summary_text']
10
+
11
+ # Create a Gradio interface with custom labels
12
+ interface = gr.Interface(fn=generate_summary,
13
+ inputs=gr.Textbox(lines=10,
14
+ placeholder="Enter Text Here...",
15
+ label="Input Text for Summarization"),
16
+ outputs=gr.Textbox(label="Summarized Text"),
17
+ title="Text Summarization",
18
+ description="Enter a block of text to generate a concise summary using a Transformers model")
19
+
20
+ # Launch the interface
21
+ interface.launch()