Download app.py from Anwaree/spam-dect: direct link, hf CLI and curl.
- Browser
- Download file 657 Bytes
-
https://huggingface.co/spaces/Anwaree/spam-dect/resolve/main/app.py
- Command line
-
hf download hf://spaces/Anwaree/spam-dect/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Anwaree/spam-dect/resolve/main/app.py
657 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Charger le modèle existant depuis Hugging Face | |
| classifier = pipeline("text-classification", model="IreNkweke/HamOrSpamModel") | |
| def predict_spam(text): | |
| result = classifier(text)[0] | |
| label = result['label'] # 'LABEL_0' ou 'LABEL_1' | |
| if label in ['LABEL_0', 'Ham']: | |
| return "Ham (Not Spam)" | |
| else: | |
| return "Spam" | |
| # Interface Gradio | |
| iface = gr.Interface( | |
| fn=predict_spam, | |
| inputs=gr.Textbox(lines=4, placeholder="Enter your message here..."), | |
| outputs="text", | |
| title="Spam/Ham Classifier", | |
| description="Classifier messages as Spam or Ham" | |
| ) | |
| iface.launch() | |