adarshjha01 commited on
Commit
2062dcb
1 Parent(s): 6677187

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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",
8
+ torch_dtype = torch.bfloat16, device=0)
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 the text to summarize")],
19
+ outputs=[gr.Textbox(label="Summarized text")],
20
+ title="Text summarizer",
21
+ )
22
+ demo.launch()
23
+
24
+