christinacdl commited on
Commit
6d26cc9
1 Parent(s): 69e8360

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ classifier = pipeline(task="text-classification", model="christinacdl/XLM_RoBERTa-Clickbait-Detection-new")
5
+
6
+ def text_classification(text):
7
+ result= classifier(text)
8
+ label = result[0]['label']
9
+ score = result[0]['score']
10
+ formatted_output = f"The label is {label} with the probability {score*100:.2f}%"
11
+ return formatted_output
12
+
13
+ examples=["Your Old Passport Will Be Replaced With Smart E-passport, Here Is Everything You Need To Know", "17 Things That Are Too Real For People Who Always Drop Their Phone"]
14
+
15
+ gradio_app = gr.Interface(fn=text_classification,
16
+ inputs= gr.Textbox(lines=2, label="Text", placeholder="Enter text here..."),
17
+ outputs=gr.Textbox(lines=2, label="Text Classification Result"),
18
+ title="Is it clickbait?",
19
+ description="Enter a text to check if it is clickbait or not!",
20
+ examples=examples)
21
+
22
+
23
+ if __name__ == "__main__":
24
+ gradio_app.launch()