Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
|
| 6 |
+
|
| 7 |
+
def summary (input):
|
| 8 |
+
output = text_summary(input)
|
| 9 |
+
return output[0]['summary_text']
|
| 10 |
+
|
| 11 |
+
gr.close_all()
|
| 12 |
+
demo = gr.Interface(fn =summary,
|
| 13 |
+
inputs = [gr.Textbox(label="Input Text",lines=6)],
|
| 14 |
+
outputs=[gr.Textbox(label="Summary",lines=4)],
|
| 15 |
+
title="Text Summarizer",
|
| 16 |
+
description="Summarize your text with DistilBART model")
|
| 17 |
+
|
| 18 |
+
demo.launch()
|