email-spam-detector / app_gradio.py
yahya007's picture
Upload 5 files
1f56d0d verified
raw
history blame
1.06 kB
import gradio as gr
from utils import model_predict
def predict_spam(text):
prediction = model_predict(text)
if prediction == 1:
return "🚫 This is SPAM!"
else:
return "βœ… This is NOT spam"
# Create Gradio interface
demo = gr.Interface(
fn=predict_spam,
inputs=gr.Textbox(label="Enter email text", lines=4, placeholder="Type or paste email text here..."),
outputs=gr.Textbox(label="Prediction"),
title="Email Spam Detector",
description="Enter an email text to check if it's spam or not.",
examples=[
["CONGRATULATIONS! You've won $1,000,000 in our lottery! Click here to claim your prize now!"],
["Hi Sarah, Just following up on the project timeline we discussed yesterday. Could you send me the updated schedule?"],
["Buy now! 90% OFF luxury watches. Authentic Rolex, Omega, TAG. Limited stock!"],
["Dear Mr. Thompson, Thank you for your recent purchase. Your order #12345 has been shipped."]
]
)
if __name__ == "__main__":
demo.launch()