aitik2000 commited on
Commit
9a6388c
·
verified ·
1 Parent(s): 5e9b49a

Create app.py

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