Pravincoder commited on
Commit
988b057
Β·
verified Β·
1 Parent(s): 53b301c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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.keras.models.load_model('./saved_model.pb')
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 "Ham"
19
 
20
  # Gradio Interface
21
- iface = gr.Interface(
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
- iface.launch()
 
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()