Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from deepface import DeepFace
|
3 |
+
|
4 |
+
# Load model once
|
5 |
+
print("Loading DeepFace Model...")
|
6 |
+
model = DeepFace.build_model("VGG-Face") # Uses VGG-Face by default
|
7 |
+
|
8 |
+
# Face comparison function
|
9 |
+
def verify_faces(image1, image2):
|
10 |
+
result = DeepFace.verify(image1, image2, model_name="VGG-Face", model=model)
|
11 |
+
|
12 |
+
if result["verified"]:
|
13 |
+
return "โ
Faces Match!", f"๐ Distance Score: {result['distance']:.4f}"
|
14 |
+
else:
|
15 |
+
return "โ Faces Do Not Match!", f"๐ Distance Score: {result['distance']:.4f}"
|
16 |
+
|
17 |
+
# Gradio Interface
|
18 |
+
iface = gr.Interface(
|
19 |
+
fn=verify_faces,
|
20 |
+
inputs=[gr.Image(type="filepath"), gr.Image(type="filepath")], # Two image inputs
|
21 |
+
outputs=["text", "text"],
|
22 |
+
title="๐ Face Authentication System",
|
23 |
+
description="Upload two images to check if they belong to the same person."
|
24 |
+
)
|
25 |
+
|
26 |
+
# Launch Gradio
|
27 |
+
iface.launch(share=True)
|