sarpkantar commited on
Commit
4c54775
·
verified ·
1 Parent(s): 14d03c9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # To create interface.
14
+ iface = gr.Interface(
15
+ fn=translate, # name of the function app.
16
+ inputs=gr.inputs.Textbox(lines=10, placeholder="Enter text to summarize..."),
17
+ outputs="text"
18
+ )
19
+ iface.launch()