ericjedha commited on
Commit
19e52c3
·
1 Parent(s): c441f1e

Bert again

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from transformers import BertConfig, BertModel
4
+
5
+ config = BertConfig()
6
+ model = BertModel(config)
7
+
8
+ model = BertModel.from_pretrained("EricJedha/spam_finetuned_bert_overf")
9
+
10
+ from transformers import AutoTokenizer
11
+ from transformers import pipeline
12
+
13
+
14
+
15
+ tokenizer = AutoTokenizer.from_pretrained(model)
16
+ def check_spam(text):
17
+ classifier = pipeline("text-classification", model="EricJedha/spam_finetuned_bert_overf")
18
+ return classifier(text)[0]['label']
19
+
20
+ with gr.Blocks() as demo:
21
+ with gr.Row():
22
+ with gr.Column():
23
+ sms = gr.Textbox(label = "SMS à checker")
24
+ spam_check_btn = gr.Button(label="Check")
25
+ with gr.Column():
26
+ result = gr.Textbox(label="Resultat de l'Analyse")
27
+
28
+ spam_check_btn.click(check_spam, input = sms, outputs = result)
29
+
30
+ demo.launch(share=True)