Bin ZHANG
commited on
Commit
•
ca51f45
1
Parent(s):
9c4df3b
demo file
Browse files- demo_app.py +14 -0
demo_app.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
summarizer = pipeline("summarization",model="t5-base",tokenizer="t5-smaller",truncation=True,framework="tf")
|
4 |
+
|
5 |
+
def translate(text):
|
6 |
+
text = text.replace(""",'"').replace("'","'").replace("&","&")
|
7 |
+
result = summarizer(text,min_length=180,truncation=True)
|
8 |
+
return result[0]["summary_text"]
|
9 |
+
|
10 |
+
iface = gr.Interface(fn=translate,
|
11 |
+
input = gr.inputs.Textbox(lines=10,placeholder="Enter text to summarize..."),
|
12 |
+
outputs="text")
|
13 |
+
|
14 |
+
iface.launch()
|