import gradio as gr import pickle # Load the trained spam classifier model with open('spam_classifier_model.pkl', 'rb') as file: loaded_model = pickle.load(file) #a='
Spam
' #b='
Not Spam
' # Prediction function def predict_spam(email_text): prediction = loaded_model.predict([email_text]) if prediction[0] == 1: return ( f'
Spam
' ) else: return ( f'
Not Spam
' ) # Define the Gradio interface interface = gr.Interface( theme=gr.themes.Citrus( primary_hue="cyan", neutral_hue="neutral" ), fn=predict_spam, inputs=gr.Textbox( label="Email Content", lines=3, placeholder="Enter the email content here..." ), outputs=gr.HTML(label="Output"),# Single output styled for size title="Email Spam Classifier", description="Enter an email's content to check if it's Spam or Not Spam." ) # Launch the Gradio app interface.launch()