Kunal Zaveri commited on
Commit
7681b3c
1 Parent(s): 15146d3

Add the model for summarize the text

Browse files
Files changed (1) hide show
  1. summarize_text.py +24 -0
summarize_text.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ # Use a pipeline as a high-level helper
4
+ from transformers import pipeline
5
+
6
+ # text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
7
+
8
+ text_summary = pipeline("summarization", model="Falconsai/text_summarization")
9
+
10
+
11
+ def summary(input):
12
+ output = text_summary(input)
13
+ return output[0]['summary_text']
14
+
15
+
16
+ gr.close_all()
17
+
18
+ # demo = gr.Interface(fn=summary, inputs="text",outputs="text")
19
+ demo = gr.Interface(fn=summary,
20
+ inputs=[gr.Textbox(label="Input text to summarize", lines=6)],
21
+ outputs=[gr.Textbox(label="Summarized text", lines=4)],
22
+ title="Text Summarizer",
23
+ description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT")
24
+ demo.launch(share=True)