Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Use a pipeline as a high-level helper
|
| 5 |
+
from transformers import pipeline
|
| 6 |
+
|
| 7 |
+
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def summary (input):
|
| 11 |
+
output = text_summary(input)
|
| 12 |
+
return output[0]['summary_text']
|
| 13 |
+
|
| 14 |
+
gr.close_all()
|
| 15 |
+
|
| 16 |
+
# demo = gr.Interface(fn=summary, inputs="text",outputs="text")
|
| 17 |
+
demo = gr.Interface(fn=summary,
|
| 18 |
+
inputs=[gr.Textbox(label="Input text to summarize",lines=6)],
|
| 19 |
+
outputs=[gr.Textbox(label="Summarized text",lines=4)],
|
| 20 |
+
title="@GenAILearniverse Project 1: Text Summarizer",
|
| 21 |
+
description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT")
|
| 22 |
+
demo.launch()
|