Tejashree sakhare commited on
Commit
1b36337
·
verified ·
1 Parent(s): ac485b8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-6-6",
8
+ torch_dtype=torch.bfloat16)
9
+
10
+ # text='''Elon Reeve Musk (/ˈiːlɒn/ EE-lon; born June 28, 1971) is a businessman and investor.
11
+ # He is the founder, chairman, CEO, and CTO of SpaceX; angel investor, CEO, product architect,
12
+ # and former chairman of Tesla, Inc.; owner, executive chairman, and CTO of X Corp.;
13
+ # founder of the Boring Company and xAI; co-founder of Neuralink and OpenAI; and president
14
+ # of the Musk Foundation. He is one of the wealthiest people in the world; as of April 2024,
15
+ # Forbes estimates his net worth to be $178 billion.[4]'''
16
+ # print(text_summary(text))
17
+
18
+ def summary(input):
19
+ output = text_summary(input)
20
+ return output[0]['summary_text']
21
+
22
+ gr.close_all()
23
+
24
+ demo = gr.Interface(fn=summary,
25
+ inputs=[gr.Textbox(label="Input text to summarize", lines=6)],
26
+ outputs=[gr.Textbox(label="Summarized text", lines=4)],
27
+ title="GenAI Project 1 - Text Summarization",
28
+ description="This application summarizes text")
29
+ demo.launch()