Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,19 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
|
|
|
| 4 |
summarizer = pipeline("summarization")
|
| 5 |
|
|
|
|
| 6 |
def summarize_text(text):
|
| 7 |
-
|
| 8 |
-
return "Please enter some text."
|
| 9 |
-
summary = summarizer(text, max_length=150, min_length=30, do_sample=False)
|
| 10 |
return summary[0]['summary_text']
|
| 11 |
|
| 12 |
-
|
|
|
|
| 13 |
fn=summarize_text,
|
| 14 |
-
inputs=gr.Textbox(lines=
|
| 15 |
-
outputs="
|
| 16 |
-
title="📝
|
| 17 |
-
description="Paste
|
| 18 |
-
)
|
| 19 |
-
|
| 20 |
-
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load the summarization pipeline
|
| 5 |
summarizer = pipeline("summarization")
|
| 6 |
|
| 7 |
+
# Function to summarize text
|
| 8 |
def summarize_text(text):
|
| 9 |
+
summary = summarizer(text, max_length=130, min_length=30, do_sample=False)
|
|
|
|
|
|
|
| 10 |
return summary[0]['summary_text']
|
| 11 |
|
| 12 |
+
# Create Gradio Interface
|
| 13 |
+
gr.Interface(
|
| 14 |
fn=summarize_text,
|
| 15 |
+
inputs=gr.Textbox(lines=10, label="Enter Text to Summarize"),
|
| 16 |
+
outputs=gr.Textbox(label="Summary"),
|
| 17 |
+
title="📝 Text Summarizer",
|
| 18 |
+
description="Paste a paragraph and get a quick summary using a Hugging Face transformer model."
|
| 19 |
+
).launch()
|
|
|
|
|
|