Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import string
|
| 3 |
-
# Load trained model and vectorizer
|
| 4 |
-
model = joblib.load("svm_model.pkl")
|
| 5 |
-
tfidf_vectorizer = joblib.load("tfidf_vectorizer.pkl")
|
| 6 |
-
|
| 7 |
-
# Simple text cleaning
|
| 8 |
-
def clean_text(text):
|
| 9 |
-
text = ''.join([char for char in text if char not in string.punctuation])
|
| 10 |
-
return text.lower()
|
| 11 |
-
|
| 12 |
-
# Prediction function
|
| 13 |
-
def classify_email(email_text):
|
| 14 |
-
clean_email = clean_text(email_text)
|
| 15 |
-
email_vector = tfidf_vectorizer.transform([clean_email])
|
| 16 |
-
prediction = model.predict(email_vector)[0]
|
| 17 |
-
return "Spam Mail 🚨" if prediction == 1 else "Ham Mail ✅"
|
| 18 |
-
|
| 19 |
# Gradio interface
|
| 20 |
iface = gr.Interface(
|
| 21 |
fn=classify_email,
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
# Gradio interface
|
| 4 |
iface = gr.Interface(
|
| 5 |
fn=classify_email,
|