Spaces:
Build error
Build error
import gradio as gr | |
import tensorflow as tf | |
import numpy as np | |
from tensorflow.keras.preprocessing.sequence import pad_sequences | |
import pickle | |
# Load the trained model | |
model = pickle.load(open('./model_file.pkl','rb') | |
def spam_detection(message): | |
# Preprocess the input message | |
sequence = tokenizer.texts_to_sequences([message]) | |
padded_sequence = pad_sequences(sequence, maxlen=max_length, padding=padding_type, truncating=trunc_type) | |
# Make prediction | |
prediction = model.predict(padded_sequence)[0, 0] | |
# Return the result | |
return "Spam" if prediction >= 0.5 else "Not Spam" | |
# Gradio Interface | |
ui = gr.Interface( | |
fn=spam_detection, | |
inputs=gr.Textbox(prompt="Enter a message:"), | |
outputs="text", | |
live=True, | |
theme="huggingface", | |
title='π« Spam Message Detection π΅οΈββοΈ', | |
description=""" | |
Welcome to the Spam Message Detection appβa powerful demo designed for learning purposes. π This application employs advanced machine learning techniques to identify and flag spam messages with remarkable accuracy. π€ With a training set accuracy of 99.89% and a validation/test set accuracy of 98.39%, the model has been fine-tuned using a comprehensive dataset. | |
**π Key Features:** | |
- State-of-the-art machine learning model | |
- High accuracy: 99.89% on the training set, 98.39% on the validation/test set | |
- Intuitive user interface for easy interaction | |
- Ideal for educational purposes and exploring spam detection techniques | |
**π Instructions:** | |
1. Enter a text message in the provided input box. | |
2. Click the "Detect" button to initiate the spam detection process. | |
3. Receive instant feedback on whether the input message is classified as spam or not. | |
**π Note: ** | |
This app is a demonstration and educational tool. It showcases the effectiveness of machine learning in identifying spam messages. Enjoy exploring the world of spam detection with our highly accurate model! π""" | |
) | |
# Launch the app | |
ui.launch() | |