File size: 869 Bytes
07c177b
d5ccd37
07c177b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d5ccd37
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from transformers import pipeline
import gradio as gr

# Load the pipeline from your Hugging Face model
pipe = pipeline("text-classification", model="ZachBeesley/Spam-Detector")

# Function to process the input text and return the predicted label
def predict(text):
    # Use the pipeline to classify the text
    result = pipe(text)

    # Extract the predicted label and confidence score
    label = result[0]["label"]
    confidence = result[0]["score"]

    # Return the result
    return f"Predicted label: {label}\nConfidence: {confidence:.2f}"

# Create the Gradio interface
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."
)

# Launch the interface
iface.launch()