neena2024 commited on
Commit
9cfbb21
·
verified ·
1 Parent(s): becf11c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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", torch_dtype=torch.bfloat16)
8
+
9
+ # For Local we can use this only
10
+ # text = "Elon Reeve Musk FRS (/ˈiːlɒn/; born June 28, 1971) is a businessman known for his key roles in the space company SpaceX and the automotive company Tesla, Inc. His other involvements include ownership of X Corp., the company that operates the social media platform X (formerly Twitter), and his role in the founding of the Boring Company, xAI, Neuralink, and OpenAI. Musk is the wealthiest individual in the world; as of November 2024, Forbes estimates his net worth to be US$323 billion"
11
+ # print(text_summary(text))
12
+
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,
21
+ inputs=[gr.Textbox(label="Input text to summarize", lines=6)],
22
+ outputs=[gr.Textbox(label="Summarized text", lines=10)],
23
+ title = "Gen AI Text Summarization",
24
+ description= "Enter details text the tool will give you summarized text"
25
+ )
26
+ demo.launch(share=True)