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()