Spaces:
Paused
Paused
Download app.py from middle77/trywk2priv: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/middle77/trywk2priv/resolve/main/app.py
- Command line
-
hf download hf://spaces/middle77/trywk2priv/app.py
-
curl -L -o app.py https://huggingface.co/spaces/middle77/trywk2priv/resolve/main/app.py
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() |