pradeepiisc commited on
Commit
af2030e
1 Parent(s): 07006f8

modify application with summarization

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -1,7 +1,21 @@
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
2
 
3
  def greet(name):
4
  return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
7
  iface.launch()
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ summarizer = pipeline("summarization", model="t5-base", tokenizer="t5=small", truncation=True, framework="tf")
5
+
6
+ def translate(text):
7
+ text = text.replace('"', '"')
8
+ text = text.replace(''', "'")
9
+ text = text.replace('&', "&")
10
+ result = summarizer(text, min_length=180, truncation=True)
11
+ return result[0]["summary_text"]
12
 
13
  def greet(name):
14
  return "Hello " + name + "!!"
15
 
16
+
17
+
18
+ # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
19
+ iface = gr.Interface(fn=translate, inputs=gr.inputs.Textbox(lines=10, placeholder="Enter text to summarize..."),
20
+ outputs="text")
21
  iface.launch()