Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,27 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
pipe = pipeline("
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
return
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
)
|
| 20 |
|
| 21 |
-
# Launch the app
|
| 22 |
if __name__ == "__main__":
|
| 23 |
-
|
|
|
|
| 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"),
|
| 20 |
+
outputs=gr.Textbox(label="Summarized Text"),
|
| 21 |
+
title=title,
|
| 22 |
+
description=description,
|
| 23 |
)
|
| 24 |
|
| 25 |
+
# Launch the Gradio app
|
| 26 |
if __name__ == "__main__":
|
| 27 |
+
interface.launch()
|