Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
import gradio as gr
|
| 3 |
+
from transformers import pipeline
|
| 4 |
|
| 5 |
+
# Choose model (either one of the two below)
|
| 6 |
+
model_name = "Falconsai/text_summarization" # or "facebook/bart-large-cnn"
|
| 7 |
+
summarizer = pipeline("summarization", model=model_name)
|
| 8 |
+
|
| 9 |
+
def summarize(text):
|
| 10 |
+
summary = summarizer(text, max_length=150, min_length=30, do_sample=False)
|
| 11 |
+
return summary[0]["summary_text"]
|
| 12 |
+
|
| 13 |
+
iface = gr.Interface(
|
| 14 |
+
fn=summarize,
|
| 15 |
+
inputs=gr.Textbox(lines=10, placeholder="Enter long text here..."),
|
| 16 |
+
outputs=gr.Textbox(label="Summary"),
|
| 17 |
+
allow_flagging="never",
|
| 18 |
+
title="Text Summarizer"
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
iface.launch()
|