awais0300 commited on
Commit
4652f1b
·
verified ·
1 Parent(s): 2c194f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -3,7 +3,7 @@ import tensorflow as tf
3
  import numpy as np
4
  import cv2
5
 
6
- # Load your SavedModel folder
7
  model = tf.keras.models.load_model("mask_mobilenet_savedmodel")
8
 
9
  def predict_mask(image):
@@ -17,8 +17,9 @@ def predict_mask(image):
17
  image = image / 255.0
18
  image = np.expand_dims(image, axis=0)
19
 
20
- # Predict using SavedModel callable
21
- preds = model(image, training=False).numpy()
 
22
  result = "Mask" if preds[0][0] > 0.5 else "No Mask"
23
  return result
24
 
 
3
  import numpy as np
4
  import cv2
5
 
6
+ # Load the SavedModel
7
  model = tf.keras.models.load_model("mask_mobilenet_savedmodel")
8
 
9
  def predict_mask(image):
 
17
  image = image / 255.0
18
  image = np.expand_dims(image, axis=0)
19
 
20
+ # Use the 'call' method instead of calling the object
21
+ preds = model.call(tf.convert_to_tensor(image), training=False).numpy()
22
+
23
  result = "Mask" if preds[0][0] > 0.5 else "No Mask"
24
  return result
25