Ojobo commited on
Commit
2880c78
·
verified ·
1 Parent(s): 995c730

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+
5
+ # Use a pipeline as a high-level helper
6
+ from transformers import pipeline
7
+
8
+
9
+ text_summary = pipeline("summarization", model="sshleifer--distilbart-cnn-6-6", torch_dtype=torch.bfloat16)
10
+
11
+ # text ='''Nigeria has been home to several indigenous material cultures, precolonial states and kingdoms since the second millennium BC'''
12
+ # print (text_summary(text))
13
+
14
+ def summary(input):
15
+ output = text_summary(input)
16
+ return output [0]['summary_text']
17
+
18
+ gr.close_all()
19
+
20
+ #demo = gr.Interface(fn=summary, input="text", output="text")
21
+
22
+ demo = gr.Interface(fn=summary,
23
+ input =[gr.Textbox(label="Input text to summarize", lines=6)],
24
+ output=[gr.Textbox(label="summarized text", lines=4)], title ="@My GenAI Project 16: Text-summarizer",
25
+ description ="This application would be used to summarize text")
26
+
27
+ demo.launch()
28
+