sprklinginfo commited on
Commit
fc7b361
·
verified ·
1 Parent(s): 5afd677

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # Use a pipeline as a high-level helper
8
+ from transformers import pipeline
9
+
10
+ text_summarize = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
11
+
12
+
13
+ def summary(input_text):
14
+ output_text = text_summarize(input_text)
15
+ return output_text[0]['summary_text']
16
+
17
+
18
+ gr.close_all()
19
+
20
+ # demo = gr.Interface(fn=summary, inputs="text", outputs="text")
21
+ demo = gr.Interface(fn=summary,
22
+ inputs=[gr.Textbox(label="Input text to summarize", lines=10)],
23
+ outputs=[gr.Textbox(label="Summarized text", lines=5)])
24
+
25
+ demo.launch()
26
+
27
+