oki7676 commited on
Commit
44645ff
·
verified ·
1 Parent(s): 789c004

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="facebook/bart-large-cnn", torch_dtype=torch.bfloat16)
8
+
9
+ # model_path = ("../Model/models--facebook--bart-large-cnn/snapshots/37f520fa929c961707657b28798b30c003dd100b")
10
+ # text_summary = pipeline("summarization", model=model_path,
11
+ # torch_dtype=torch.bfloat16)
12
+
13
+ # text="""
14
+ # The tower is 324 metres (1,063 ft) tall, about the same height as
15
+ # an 81-storey building, and the tallest structure in Paris. Its base
16
+ # is square, measuring 125 metres (410 ft) on each side. During its
17
+ # construction, the Eiffel Tower surpassed the Washington Monument to
18
+ # become the tallest man-made structure in the world, a title it held
19
+ # for 41 years until the Chrysler Building in New York City was finished in 1930.
20
+ # It was the first structure to reach a height of 300 metres. Due to the addition
21
+ # of a broadcasting aerial at the top of the tower in 1957, it is now taller than
22
+ # the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel
23
+ # Tower is the second tallest free-standing structure in France after the Millau Viaduct.
24
+ # """
25
+ # print(text_summary(text));
26
+
27
+ def summary (input):
28
+ output = text_summary(input)
29
+ return output[0]['summary_text']
30
+
31
+ gr.close_all()
32
+
33
+ # demo = gr.Interface(fn=summary, inputs="text", outputs="text")
34
+ demo = gr.Interface(fn=summary,
35
+ inputs=[gr.Textbox(label="Input text to summarize",lines=6)],
36
+ outputs=[gr.Textbox(label="Summarized text",lines=4)],
37
+ title="EQNZ Text Summarizer",
38
+ description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT")
39
+
40
+ demo.launch()