Face-Similarity / app.py
Sk1306's picture
Create app.py
48681cf verified
raw
history blame
878 Bytes
import gradio as gr
from deepface import DeepFace
# Load model once
print("Loading DeepFace Model...")
model = DeepFace.build_model("VGG-Face") # Uses VGG-Face by default
# Face comparison function
def verify_faces(image1, image2):
result = DeepFace.verify(image1, image2, model_name="VGG-Face", model=model)
if result["verified"]:
return "βœ… Faces Match!", f"πŸ” Distance Score: {result['distance']:.4f}"
else:
return "❌ Faces Do Not Match!", f"πŸ” Distance Score: {result['distance']:.4f}"
# Gradio Interface
iface = gr.Interface(
fn=verify_faces,
inputs=[gr.Image(type="filepath"), gr.Image(type="filepath")], # Two image inputs
outputs=["text", "text"],
title="πŸ” Face Authentication System",
description="Upload two images to check if they belong to the same person."
)
# Launch Gradio
iface.launch(share=True)