Spaces:
Sleeping
Sleeping
kasper-boy
commited on
Commit
•
28f97a8
1
Parent(s):
51032e9
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
def summary (input):
|
10 |
+
output = text_summary(input)
|
11 |
+
return output[0]['summary_text']
|
12 |
+
|
13 |
+
gr.close_all()
|
14 |
+
|
15 |
+
# demo = gr.Interface(fn=summary, inputs="text",outputs="text")
|
16 |
+
demo = gr.Interface(fn=summary,
|
17 |
+
inputs=[gr.Textbox(label="Input text to summarize",lines=6)],
|
18 |
+
outputs=[gr.Textbox(label="Summarized text",lines=4)],
|
19 |
+
title="@GenAILearniverse Project 1: Text Summarizer",
|
20 |
+
description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT")
|
21 |
+
demo.launch()
|