poojavijith commited on
Commit
ddf9d5b
·
verified ·
1 Parent(s): 80ebedb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -0
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-xsum-9-6",
8
+ torch_dtype=torch.bfloat16)
9
+
10
+
11
+ #model_path =("../models/models--sshleifer--distilbart-xsum-9-6/snapshots"
12
+ # "/28dfbe915f475094642bf8c7dba2ba8a8e85b432")
13
+ #text_summary = pipeline("summarization", model=model_path,
14
+ # torch_dtype=torch.bfloat16)
15
+
16
+
17
+ #text=("India, officially the Republic of India,[j][20] is a country in South Asia. "
18
+ # "It is the seventh-largest country by area; the most populous country since 2023;[21]"
19
+ # " and, since its independence in 1947, the world's most populous democracy.[22][23][24] Bounded by "
20
+ # "the Indian Ocean on the south, "
21
+ #"the Arabian Sea on the southwest, and the Bay of Bengal on the southeast, it shares land borders"
22
+ #" with Pakistan to the west;"
23
+ #"[k] China, Nepal, and Bhutan to the north; and Bangladesh and Myanmar to the east. In the Indian Ocean, "
24
+ #"India is near Sri Lanka and the Maldives; "
25
+ #"its Andaman and Nicobar Islands share a maritime border with Thailand, Myanmar, and Indonesia.")
26
+
27
+
28
+ #print(text_summary(text));
29
+
30
+ def summary(input):
31
+ output = text_summary(input)
32
+ return output[0]['summary_text']
33
+
34
+ gr.close_all()
35
+
36
+ #demo=gr.Interface(fn=summary,inputs="text",outputs="text")
37
+ demo = gr.Interface(fn=summary,
38
+ inputs=[gr.Textbox(label="Input Text to Summarize",lines=6)],
39
+
40
+ outputs=[gr.Textbox(label="summarized text",lines=4)],
41
+ title="AMRITA TEXT SUMMARIZER",
42
+ description="THIS APPLICATION IS USED TO SUMMARIZE THE TEXT")
43
+
44
+
45
+
46
+
47
+
48
+ demo.launch(share=True)
49
+