Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,8 @@ model1 = from_pretrained_keras("arsath-sm/real-fake-face-detection-model1")
|
|
8 |
model2 = from_pretrained_keras("arsath-sm/real-fake-face-detection-model2")
|
9 |
|
10 |
def preprocess_image(image):
|
11 |
-
img = tf.
|
|
|
12 |
img = img / 255.0
|
13 |
return tf.expand_dims(img, 0)
|
14 |
|
@@ -21,7 +22,6 @@ def predict_image(image):
|
|
21 |
|
22 |
# Average the predictions
|
23 |
avg_pred = (pred1 + pred2) / 2
|
24 |
-
|
25 |
result = "Real" if avg_pred > 0.5 else "Fake"
|
26 |
confidence = avg_pred if avg_pred > 0.5 else 1 - avg_pred
|
27 |
|
|
|
8 |
model2 = from_pretrained_keras("arsath-sm/real-fake-face-detection-model2")
|
9 |
|
10 |
def preprocess_image(image):
|
11 |
+
img = tf.convert_to_tensor(image)
|
12 |
+
img = tf.image.resize(img, (150, 150))
|
13 |
img = img / 255.0
|
14 |
return tf.expand_dims(img, 0)
|
15 |
|
|
|
22 |
|
23 |
# Average the predictions
|
24 |
avg_pred = (pred1 + pred2) / 2
|
|
|
25 |
result = "Real" if avg_pred > 0.5 else "Fake"
|
26 |
confidence = avg_pred if avg_pred > 0.5 else 1 - avg_pred
|
27 |
|