Spaces:
Sleeping
Sleeping
Init app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
summarizer = pipeline("summarization", model="Afsara/fb_bart_large_cnn")
|
| 5 |
+
|
| 6 |
+
def summarize(input):
|
| 7 |
+
output = summarizer(input, max_length=130, min_length=30, do_sample=False)
|
| 8 |
+
return output[0]['summary_text']
|
| 9 |
+
|
| 10 |
+
gr.close_all()
|
| 11 |
+
|
| 12 |
+
demo = gr.Interface(fn=summarize,
|
| 13 |
+
inputs=[gr.Textbox(label="Text to summarize", lines=6)],
|
| 14 |
+
outputs=[gr.Textbox(label="Result", lines=3)],
|
| 15 |
+
title="Text summarization with distilbart-cnn",
|
| 16 |
+
description="Summarize any text using the `shleifer/distilbart-cnn-12-6` model under the hood!"
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
demo.launch()
|