astro21 commited on
Commit
1dc4ba4
1 Parent(s): 4cf87c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -9,9 +9,21 @@ def summarize_text(input_text):
9
  summarized_text = summarizer(input_text, max_length=128, min_length=64, do_sample=False , wait_for_model = True)
10
  return summarized_text[0]['summary_text']
11
 
12
- gr.Interface(
13
- fn=summarize_text,
 
 
 
 
 
 
14
  inputs=gr.inputs.Textbox(label="Enter the text to summarize"),
15
  outputs=gr.outputs.Textbox(label="Summarized Text"),
16
  title="Text Summarizer",
17
- ).launch()
 
 
 
 
 
 
 
9
  summarized_text = summarizer(input_text, max_length=128, min_length=64, do_sample=False , wait_for_model = True)
10
  return summarized_text[0]['summary_text']
11
 
12
+ def summarize_with_button(text):
13
+ if text == "":
14
+ return "Please enter some text to summarize."
15
+ else:
16
+ return summarize_text(text)
17
+
18
+ iface = gr.Interface(
19
+ fn=summarize_with_button,
20
  inputs=gr.inputs.Textbox(label="Enter the text to summarize"),
21
  outputs=gr.outputs.Textbox(label="Summarized Text"),
22
  title="Text Summarizer",
23
+ live=True # Enable live updates without a "Summarize" button
24
+ )
25
+
26
+ # Add the "Summarize" button
27
+ iface.inputs.append(gr.inputs.Button(label="Summarize"))
28
+
29
+ iface.launch()