Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import tensorflow as tf
|
|
| 3 |
import numpy as np
|
| 4 |
import cv2
|
| 5 |
|
| 6 |
-
# Load
|
| 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 |
-
#
|
| 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 |
|