trywk2priv / app.py
middle77's picture
Upload 2 files
f1f47b0 verified
Raw History Blame Contribute Delete
1.11 kB
"""
app.py
Gradio demo for the spam classifier.
Deploy this file (plus requirements.txt) to a Hugging Face Space
(SDK: Gradio) to get a public shareable link.
"""
import gradio as gr
from inference import predict
def classify(text):
if not text.strip():
return "Enter a message above."
result = predict(text)
return f"{result['label'].upper()} (confidence: {result['score']:.2%})"
demo = gr.Interface(
fn=classify,
inputs=gr.Textbox(
lines=4,
placeholder="Paste a text message or email snippet here...",
label="Message",
),
outputs=gr.Textbox(label="Prediction"),
title="Spam Classifier",
description=(
"Classifies a message as SPAM or HAM using "
"mrm8488/bert-tiny-finetuned-sms-spam-detection."
),
examples=[
["Congratulations! You've won a free cruise, call now to claim your prize!"],
["Hey, are we still on for lunch tomorrow?"],
["URGENT: verify your account now or it will be suspended."],
],
)
if __name__ == "__main__":
demo.launch()