Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load the summarization pipeline with the BART model
|
5 |
pipe = pipeline("summarization", model="facebook/bart-large-cnn")
|
6 |
|
7 |
def summarize_text(text):
|
8 |
-
# Use the summarization pipeline to summarize the input text
|
9 |
summary = pipe(text, max_length=150, min_length=40, do_sample=False)
|
10 |
return summary[0]['summary_text']
|
11 |
|
12 |
-
# Gradio interface setup
|
13 |
title = "Text Summarization with BART"
|
14 |
description = "Provide a block of text, and the BART model will summarize it."
|
15 |
|
16 |
-
# Create Gradio interface
|
17 |
interface = gr.Interface(
|
18 |
fn=summarize_text,
|
19 |
inputs=gr.Textbox(lines=10, label="Input Text"),
|
@@ -22,6 +18,5 @@ interface = gr.Interface(
|
|
22 |
description=description,
|
23 |
)
|
24 |
|
25 |
-
# Launch the Gradio app
|
26 |
if __name__ == "__main__":
|
27 |
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
|
|
4 |
pipe = pipeline("summarization", model="facebook/bart-large-cnn")
|
5 |
|
6 |
def summarize_text(text):
|
|
|
7 |
summary = pipe(text, max_length=150, min_length=40, do_sample=False)
|
8 |
return summary[0]['summary_text']
|
9 |
|
|
|
10 |
title = "Text Summarization with BART"
|
11 |
description = "Provide a block of text, and the BART model will summarize it."
|
12 |
|
|
|
13 |
interface = gr.Interface(
|
14 |
fn=summarize_text,
|
15 |
inputs=gr.Textbox(lines=10, label="Input Text"),
|
|
|
18 |
description=description,
|
19 |
)
|
20 |
|
|
|
21 |
if __name__ == "__main__":
|
22 |
interface.launch()
|