GenAILearniverse commited on
Commit
f84aae5
1 Parent(s): d449ee2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # model_path = ("../Models/models--sshleifer--distilbart-cnn-12-6/snapshots"
10
+ # "/a4f8f3ea906ed274767e9906dbaede7531d660ff")
11
+ # text_summary = pipeline("summarization", model=model_path,
12
+ # torch_dtype=torch.bfloat16)
13
+
14
+
15
+
16
+ # text='''Elon Reeve Musk (/ˈiːlɒn/ EE-lon; born June 28, 1971) is a businessman and investor.
17
+ # He is the founder, chairman, CEO, and CTO of SpaceX; angel investor, CEO, product architect,
18
+ # and former chairman of Tesla, Inc.; owner, executive chairman, and CTO of X Corp.;
19
+ # founder of the Boring Company and xAI; co-founder of Neuralink and OpenAI; and president
20
+ # of the Musk Foundation. He is one of the wealthiest people in the world; as of April 2024,
21
+ # Forbes estimates his net worth to be $178 billion.[4]'''
22
+ # print(text_summary(text));
23
+
24
+ def summary (input):
25
+ output = text_summary(input)
26
+ return output[0]['summary_text']
27
+
28
+ gr.close_all()
29
+
30
+ # demo = gr.Interface(fn=summary, inputs="text",outputs="text")
31
+ demo = gr.Interface(fn=summary,
32
+ inputs=[gr.Textbox(label="Input text to summarize",lines=6)],
33
+ outputs=[gr.Textbox(label="Summarized text",lines=4)],
34
+ title="@GenAILearniverse Project 1: Text Summarizer",
35
+ description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT")
36
+ demo.launch()
37
+
38
+
39
+