Sk1306 commited on
Commit
48681cf
ยท
verified ยท
1 Parent(s): 39e417d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
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)