|
from transformers import pipeline |
|
import gradio as gr |
|
|
|
|
|
pipe = pipeline("text-classification", model="ZachBeesley/Spam-Detector") |
|
|
|
|
|
def predict(text): |
|
try: |
|
|
|
result = pipe(text) |
|
|
|
|
|
label = result[0]["label"] |
|
confidence = result[0]["score"] |
|
|
|
|
|
return f"Predicted label: {label}\nConfidence: {confidence:.2f}" |
|
except Exception as e: |
|
|
|
return f"Error: {str(e)}" |
|
|
|
|
|
iface = gr.Interface( |
|
fn=predict, |
|
inputs=gr.Textbox(label="Email Text", placeholder="Paste your email text here..."), |
|
outputs="text", |
|
title="Spam Email Detector", |
|
description="Enter an email and find out if it's spam or not." |
|
) |
|
|
|
|
|
iface.launch() |
|
|