Anwaree commited on
Commit
c22ee64
·
verified ·
1 Parent(s): e618af4

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
+ # Charger le modèle existant depuis Hugging Face
5
+ classifier = pipeline("text-classification", model="IreNkweke/HamOrSpamModel")
6
+
7
+ def predict_spam(text):
8
+ result = classifier(text)[0]
9
+ label = result['label'] # 'LABEL_0' ou 'LABEL_1'
10
+ if label in ['LABEL_0', 'Ham']:
11
+ return "Ham (Not Spam)"
12
+ else:
13
+ return "Spam"
14
+
15
+ # Interface Gradio
16
+ iface = gr.Interface(
17
+ fn=predict_spam,
18
+ inputs=gr.Textbox(lines=4, placeholder="Enter your message here..."),
19
+ outputs="text",
20
+ title="Spam/Ham Classifier",
21
+ description="Classifier messages as Spam or Ham using a pre-trained model."
22
+ )
23
+
24
+ iface.launch()