Spaces:
Sleeping
Sleeping
Create text_summarize.py
Browse files- text_summarize.py +14 -0
text_summarize.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
from transformers import pipeline
|
| 5 |
+
|
| 6 |
+
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
|
| 7 |
+
|
| 8 |
+
def summarize (text):
|
| 9 |
+
output = text_summary(text)
|
| 10 |
+
return output[0]['summary_text']
|
| 11 |
+
|
| 12 |
+
gr.close_all()
|
| 13 |
+
app = gr.Interface(fn=summarize,inputs=gr.Textbox(label="Plug in your text here to summarize", lines=10, placeholder="Enter text to summarize..."), outputs=gr.Textbox(label="Summary", lines=5, placeholder="Summary will appear here..."), title="Text-Summarizer", description="This application summarizes the input text.", theme="default")
|
| 14 |
+
app.launch()
|