Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,24 +6,14 @@ summarizer = pipeline("summarization", model="astro21/bart-cls")
|
|
6 |
|
7 |
def summarize_text(input_text):
|
8 |
# Use the summarization pipeline to generate a summary
|
9 |
-
summarized_text = summarizer(input_text, max_length=128, min_length=64, do_sample=False
|
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=
|
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 |
-
|
27 |
-
iface.inputs.append(gr.inputs.Button(label="Summarize"))
|
28 |
-
|
29 |
-
iface.launch()
|
|
|
6 |
|
7 |
def summarize_text(input_text):
|
8 |
# Use the summarization pipeline to generate a summary
|
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 |
iface = 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 |
)
|
18 |
|
19 |
+
iface.launch()
|
|
|
|
|
|