Spaces:
Sleeping
Sleeping
change app to a text summarizer
Browse files
app.py
CHANGED
@@ -1,7 +1,32 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
-
iface.launch()
|
|
|
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()
|
8 |
+
|
9 |
+
from transformers import pipeline
|
10 |
+
|
11 |
+
nlp = pipeline("sentiment-analysis")
|
12 |
+
|
13 |
+
summurizer = pipeline( "summarization",
|
14 |
+
model="t5-base",
|
15 |
+
tokenizer = "t5-small",
|
16 |
+
truncuation = True,
|
17 |
+
framework ="tf" )
|
18 |
+
|
19 |
+
def translate(text):
|
20 |
+
text = text.replace('"', '"')
|
21 |
+
text = text.replace('&apos', "'")
|
22 |
+
text = text.replace('&', '&')
|
23 |
+
result = summurizer(text, min_length= 180, truncuation=True)
|
24 |
+
return result[0]["summary_text"]
|
25 |
+
|
26 |
+
|
27 |
+
iface = gr.Interface( fn=translate,
|
28 |
+
inputs= gr.inputs.Textbox(lines=10, placeholder= "Enter a text to summurize ..."),
|
29 |
+
outputs= "text")
|
30 |
+
|
31 |
+
iface.launch()
|
32 |
|
|
|
|