arsath-sm commited on
Commit
eb5982c
1 Parent(s): 48eec74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
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
- # Average the predictions
29
- avg_pred = (pred1 + pred2) / 2
30
- result = "Real" if avg_pred > 0.5 else "Fake"
31
- confidence = avg_pred if avg_pred > 0.5 else 1 - avg_pred
32
 
33
- return f"{result} (Confidence: {confidence:.2f})"
 
 
 
 
 
 
34
 
35
  iface = gr.Interface(
36
  fn=predict_image,
37
  inputs=gr.Image(),
38
- outputs="text",
 
 
 
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()