Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import joblib
|
| 4 |
+
model = joblib.load("svm.joblib")
|
| 5 |
+
vectorizer = joblib.load("vectorizer.joblib")
|
| 6 |
+
encoder = joblib.load("encoder.joblib")
|
| 7 |
+
# --- Fonction de prédiction ---
|
| 8 |
+
def detect_spam(message):
|
| 9 |
+
vect = vectorizer.transform([message])
|
| 10 |
+
pred = model.predict(vect)[0]
|
| 11 |
+
return "🚫 SPAM" if pred == 1 else "✅ PAS SPAM"
|
| 12 |
+
|
| 13 |
+
# --- Interface Gradio ---
|
| 14 |
+
interface = gr.Interface(
|
| 15 |
+
fn=detect_spam,
|
| 16 |
+
inputs=gr.Textbox(lines=4, placeholder="Entrez un message SMS ici..."),
|
| 17 |
+
outputs="text",
|
| 18 |
+
title="📩 Détection de Spam par SVM",
|
| 19 |
+
description="Entrez un message pour savoir s'il est classé comme spam ou non."
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
interface.launch()
|