aspendse commited on
Commit
14db8b5
·
verified ·
1 Parent(s): 1417932

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -1,20 +1,19 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
 
4
  summarizer = pipeline("summarization")
5
 
 
6
  def summarize_text(text):
7
- if text.strip() == "":
8
- return "Please enter some text."
9
- summary = summarizer(text, max_length=150, min_length=30, do_sample=False)
10
  return summary[0]['summary_text']
11
 
12
- iface = gr.Interface(
 
13
  fn=summarize_text,
14
- inputs=gr.Textbox(lines=15, placeholder="Enter your text here..."),
15
- outputs="text",
16
- title="📝 Smart Text Summarizer",
17
- description="Paste any article or paragraph and get a short summary using AI."
18
- )
19
-
20
- iface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load the summarization pipeline
5
  summarizer = pipeline("summarization")
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
+ # Create Gradio Interface
13
+ gr.Interface(
14
  fn=summarize_text,
15
+ inputs=gr.Textbox(lines=10, label="Enter Text to Summarize"),
16
+ outputs=gr.Textbox(label="Summary"),
17
+ title="📝 Text Summarizer",
18
+ description="Paste a paragraph and get a quick summary using a Hugging Face transformer model."
19
+ ).launch()