Spaces:
Sleeping
Sleeping
File size: 802 Bytes
3b45da0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from transformers import pipeline
import gradio as gr
# Load spam detection model pipeline
classifier = pipeline("text-classification", model="mrm8488/bert-tiny-finetuned-sms-spam-detection")
# Define the prediction function
def predict_spam(text):
result = classifier(text)[0]
label = result['label']
confidence = round(result['score'] * 100, 2)
return f"Prediction: {label}\nConfidence: {confidence}%"
# Gradio interface
gr.Interface(
fn=predict_spam,
inputs=gr.Textbox(lines=4, placeholder="Enter a message..."),
outputs="text",
title="Spam Detector",
description="Enter a message to check if it's spam or not using a pretrained BERT model.",
examples=["Win a free iPhone now!", "Hey, are we still on for dinner tonight?"]
).launch()
|