Shreya1687 commited on
Commit
f3a3f06
·
verified ·
1 Parent(s): 9034011

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py CHANGED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ # Use a pipeline as a high-level helper
4
+ from transformers import pipeline
5
+
6
+ # model_path = ("Models\models--sshleifer--distilbart-cnn-12-6\snapshots\a4f8f3ea906ed274767e9906dbaede7531d660ff")
7
+
8
+ #torch_dtype - compress the model
9
+ text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6",torch_dtype=torch.bfloat16)
10
+
11
+ # text="Once upon a time, while flying through the air, a stork noticed the sparkle of a ring. It belonged to a rabbit who was getting married that day. The rabbit went inside its burrow leaving the ring outside, and the stork decided to try it on quickly without asking."
12
+ # print(text_summary(text))
13
+
14
+ def summary (input):
15
+ output = text_summary(input)
16
+ return output[0]['summary_text']
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=6)],
23
+ outputs=[gr.Textbox(label="Summarized text",lines=4)],
24
+ title="@GenAILearniverse Project 1: Text Summarizer",
25
+ description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT")
26
+ demo.launch()