Zeyadd-Mostaffa commited on
Commit
be93614
·
verified ·
1 Parent(s): 6217681

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -65,15 +65,18 @@ def predict(image):
65
  label = "Real" if avg > 0.41 else "Fake"
66
  color = (0, 255, 0) if label == "Real" else (0, 0, 255)
67
 
68
- # Annotate image
69
  cv2.rectangle(output_image, (x, y), (x2, y2), color, 2)
70
- cv2.putText(output_image, f"{label} ({avg:.2f})", (x, y - 10),
71
  cv2.FONT_HERSHEY_SIMPLEX, 0.6, color, 2)
72
 
73
- results.append(f"Face {idx+1}: {label} (Avg: {avg:.3f}, XCP: {pred_xcp:.3f}, EFF: {pred_eff:.3f})")
 
 
74
 
75
  return "\n".join(results), output_image
76
 
 
77
  # Gradio Interface
78
  interface = gr.Interface(
79
  fn=predict,
 
65
  label = "Real" if avg > 0.41 else "Fake"
66
  color = (0, 255, 0) if label == "Real" else (0, 0, 255)
67
 
68
+ # Annotate image with % instead of raw float
69
  cv2.rectangle(output_image, (x, y), (x2, y2), color, 2)
70
+ cv2.putText(output_image, f"{label} ({avg * 100:.2f}%)", (x, y - 10),
71
  cv2.FONT_HERSHEY_SIMPLEX, 0.6, color, 2)
72
 
73
+ results.append(
74
+ f"Face {idx+1}: {label} (Avg: {avg * 100:.2f}%, XCP: {pred_xcp * 100:.2f}%, EFF: {pred_eff * 100:.2f}%)"
75
+ )
76
 
77
  return "\n".join(results), output_image
78
 
79
+
80
  # Gradio Interface
81
  interface = gr.Interface(
82
  fn=predict,