Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,25 @@
|
|
| 1 |
-
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
# Load the summarization pipeline
|
| 7 |
pipe = pipeline("summarization", model="Falconsai/text_summarization")
|
| 8 |
|
| 9 |
-
|
| 10 |
-
def
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
if __name__ == '__main__':
|
| 29 |
-
app.run(debug=True)
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load the summarization model
|
|
|
|
|
|
|
| 5 |
pipe = pipeline("summarization", model="Falconsai/text_summarization")
|
| 6 |
|
| 7 |
+
# Define the function to summarize text
|
| 8 |
+
def summarize_text(text):
|
| 9 |
+
if not text.strip():
|
| 10 |
+
return "Please enter some text to summarize."
|
| 11 |
+
summary = pipe(text, max_length=150, min_length=30, do_sample=False)
|
| 12 |
+
return summary[0]['summary_text']
|
| 13 |
+
|
| 14 |
+
# Create Gradio interface
|
| 15 |
+
iface = gr.Interface(
|
| 16 |
+
fn=summarize_text,
|
| 17 |
+
inputs=gr.Textbox(lines=5, placeholder="Enter text to summarize..."),
|
| 18 |
+
outputs="text",
|
| 19 |
+
title="Text Summarization App",
|
| 20 |
+
description="Enter text, and the AI will generate a concise summary.",
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# Launch the Gradio app
|
| 24 |
+
if __name__ == "__main__":
|
| 25 |
+
iface.launch()
|
|
|
|
|
|