edemgold commited on
Commit
6ec48ce
·
1 Parent(s): a2e5a1c

Add application file

Browse files
Files changed (1) hide show
  1. app.py +16 -0
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()