Spaces:
Sleeping
Sleeping
| from transformers import pipeline | |
| import gradio as gr | |
| classifier = pipeline( | |
| "text-classification", | |
| model="mariagrandury/roberta-base-finetuned-sms-spam-detection" | |
| ) | |
| def predict_spam(text): | |
| result = classifier(text)[0] | |
| label = "SPAM" if result['label'].lower() == "spam" else "HAM (Not Spam)" | |
| confidence = round(result['score'] * 100, 2) | |
| return f"Prediction: {label}\nConfidence: {confidence}%" | |
| gr.Interface( | |
| fn=predict_spam, | |
| inputs=gr.Textbox(lines=4, placeholder="Enter your message..."), | |
| outputs="text", | |
| title="Spam Detector", | |
| description="Detects whether a message is SPAM or not using a fine-tuned RoBERTa model.", | |
| examples=[ | |
| "Congratulations! You won a prize.", | |
| "Hi, are we meeting tomorrow?", | |
| "Click to claim your free iPhone!" | |
| ] | |
| ).launch() | |