SSD0907 commited on
Commit
81c7b88
·
verified ·
1 Parent(s): ff4cb43

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(task="summarization", model= "sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
8
+
9
+ # model_path = ("../models/models--sshleifer--distilbart-cnn-12-6/snapshots/a4f8f3ea906ed274767e9906dbaede7531d660ff")
10
+ # text_summary = pipeline("summarization", model=model_path, torch_dtype=torch.bfloat16)
11
+
12
+
13
+ # text = '''Elon Reeve Musk (/ˈiːlɒn/ EE-lon; born June 28, 1971) is a businessman known for his key roles in Tesla, Inc., SpaceX, and Twitter (which he rebranded as X). Since 2025, he has been a senior advisor to United States president Donald Trump and de facto head of the Department of Government Efficiency (DOGE). Musk is the wealthiest person in the world; as of February 2025, Forbes estimates his net worth to be US$353 billion.'''
14
+ # print(text_summary(text))
15
+
16
+
17
+ def summary(input):
18
+ output = text_summary(input)
19
+ return output[0]["summary_text"]
20
+
21
+ gr.close_all()
22
+ # demo = gr.Interface(fn=summary, inputs="text", outputs="text")
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="TEXT SUMMARIZER",
28
+ description="THIS APPLICATION WILL BE USED TO SUMMARIZE TEXT")
29
+ demo.launch()