roadkill007 commited on
Commit
5f41408
1 Parent(s): 298b59d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+
4
+ # Use a pipeline as a high-level helper
5
+ from transformers import pipeline
6
+
7
+ text_summary = pipeline("summarization", model="philschmid/distilbart-cnn-12-6-samsum")
8
+
9
+ # model_path = "text summarizer/models/models--philschmid--distilbart-cnn-12-6-samsum/snapshots/d8bbb0012bd874c792577caeaab58b6f72f64e2f"
10
+ # text_summary = pipeline("summarization", model=model_path,
11
+ # torch_dtype=torch.bfloat16)
12
+
13
+ # text = "Elon Reeve Musk (lɒn/ EE-lon; born June 28, 1971) is a businessman and investor. He is the founder, chairman, CEO, and CTO of SpaceX; angel investor, CEO, product architect, and former chairman of Tesla, Inc.; owner, executive chairman, and CTO of X Corp.; founder of the Boring Company and xAI; co-founder of Neuralink and OpenAI; and president of the Musk Foundation. He is one of the wealthiest people in the world; as of April 2024, Forbes estimates his net worth to be $178 billion.[4]"
14
+ # result = text_summary(text)
15
+ # print(result[0]["summary_text"])
16
+
17
+ def summary (input):
18
+ output = text_summary(input)
19
+ return output[0]['summary_text']
20
+
21
+ gr.close_all()
22
+
23
+ # demo = gr.Interface(fn = summary, inputs = "text" , outputs = "text")
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 = "PROJECT 1 : text summarizer",
28
+ description = "This applicating will be used to summarize text"
29
+ )
30
+
31
+ demo.launch()