Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,19 +25,27 @@ def predict_image(image):
|
|
25 |
pred1 = model1.predict(preprocessed_image)[0][0]
|
26 |
pred2 = model2.predict(preprocessed_image)[0][0]
|
27 |
|
28 |
-
#
|
29 |
-
|
30 |
-
|
31 |
-
confidence = avg_pred if avg_pred > 0.5 else 1 - avg_pred
|
32 |
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
iface = gr.Interface(
|
36 |
fn=predict_image,
|
37 |
inputs=gr.Image(),
|
38 |
-
outputs=
|
|
|
|
|
|
|
39 |
title="Real vs Fake Face Detection",
|
40 |
-
description="Upload an image to determine if it's a real or fake face."
|
41 |
)
|
42 |
|
43 |
iface.launch()
|
|
|
25 |
pred1 = model1.predict(preprocessed_image)[0][0]
|
26 |
pred2 = model2.predict(preprocessed_image)[0][0]
|
27 |
|
28 |
+
# Prepare results for each model
|
29 |
+
result1 = "Real" if pred1 > 0.5 else "Fake"
|
30 |
+
confidence1 = pred1 if pred1 > 0.5 else 1 - pred1
|
|
|
31 |
|
32 |
+
result2 = "Real" if pred2 > 0.5 else "Fake"
|
33 |
+
confidence2 = pred2 if pred2 > 0.5 else 1 - pred2
|
34 |
+
|
35 |
+
return (
|
36 |
+
f"Model 1: {result1} (Confidence: {confidence1:.2f})",
|
37 |
+
f"Model 2: {result2} (Confidence: {confidence2:.2f})"
|
38 |
+
)
|
39 |
|
40 |
iface = gr.Interface(
|
41 |
fn=predict_image,
|
42 |
inputs=gr.Image(),
|
43 |
+
outputs=[
|
44 |
+
gr.Textbox(label="Model 1 Prediction"),
|
45 |
+
gr.Textbox(label="Model 2 Prediction")
|
46 |
+
],
|
47 |
title="Real vs Fake Face Detection",
|
48 |
+
description="Upload an image to determine if it's a real or fake face using two different models."
|
49 |
)
|
50 |
|
51 |
iface.launch()
|