Spaces:
Runtime error
Runtime error
Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
#model
|
5 |
+
model = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") #model="sshleifer/distilbart-cnn-12-6")
|
6 |
+
|
7 |
+
def func(article):
|
8 |
+
article_length = article.split()
|
9 |
+
words = len(article_length)
|
10 |
+
if words>900:
|
11 |
+
return "Oops!😰, I can't summarize text that long, please shorten the text🥺"
|
12 |
+
else:
|
13 |
+
return (model(article, max_length=100, do_sample=False))
|
14 |
+
|
15 |
+
app = gr.Interface(fn=func, inputs="textbox", outputs="textbox", title="InfluencerAI-Summarizer")
|
16 |
+
app.launch()
|