alfredodeza commited on
Commit
cfb5d66
·
1 Parent(s): 6fd099e

Create app.py

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