basharat8763 commited on
Commit
f7380de
·
verified ·
1 Parent(s): 432bdff

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # downloaded the model from web
8
+ pipe = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6",
9
+ torch_dtype=torch.bfloat16)
10
+
11
+ # def summary(input):
12
+ # output = text_summary(input)
13
+ # return output[0]['summary_text']
14
+ #
15
+ #
16
+ gr.close_all()
17
+
18
+ # simple gradio web app
19
+ # demo = gr.Interface(fn=summary, inputs="text", outputs="text")
20
+
21
+ # beautified
22
+ demo = gr.Interface(
23
+ fn=summary,
24
+ inputs=[gr.Textbox(label="Input text to summarize", lines=6)],
25
+ outputs=[gr.Textbox(label="Summarized text", lines=4)],
26
+ title="Project 01: Text Summarization",
27
+ description="As understood from the title, if not already, this application will summarize your text"
28
+ )
29
+
30
+ demo.launch()