Pravincoder
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import numpy as np
|
|
4 |
from tensorflow.keras.preprocessing.sequence import pad_sequences
|
5 |
|
6 |
# Load the trained model
|
7 |
-
model = tf.
|
8 |
|
9 |
def spam_detection(message):
|
10 |
# Preprocess the input message
|
@@ -15,10 +15,10 @@ def spam_detection(message):
|
|
15 |
prediction = model.predict(padded_sequence)[0, 0]
|
16 |
|
17 |
# Return the result
|
18 |
-
return "Spam" if prediction >= 0.5 else "
|
19 |
|
20 |
# Gradio Interface
|
21 |
-
|
22 |
fn=spam_detection,
|
23 |
inputs=gr.Textbox(prompt="Enter a message:"),
|
24 |
outputs="text",
|
@@ -43,4 +43,4 @@ iface = gr.Interface(
|
|
43 |
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! π"""
|
44 |
)
|
45 |
# Launch the app
|
46 |
-
|
|
|
4 |
from tensorflow.keras.preprocessing.sequence import pad_sequences
|
5 |
|
6 |
# Load the trained model
|
7 |
+
model = tf.saved_model.load('./saved_model.pb')
|
8 |
|
9 |
def spam_detection(message):
|
10 |
# Preprocess the input message
|
|
|
15 |
prediction = model.predict(padded_sequence)[0, 0]
|
16 |
|
17 |
# Return the result
|
18 |
+
return "Spam" if prediction >= 0.5 else "Not Spam"
|
19 |
|
20 |
# Gradio Interface
|
21 |
+
ui = gr.Interface(
|
22 |
fn=spam_detection,
|
23 |
inputs=gr.Textbox(prompt="Enter a message:"),
|
24 |
outputs="text",
|
|
|
43 |
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! π"""
|
44 |
)
|
45 |
# Launch the app
|
46 |
+
ui.launch()
|