Spaces:
Sleeping
Sleeping
File size: 729 Bytes
1290ec4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from deepface import DeepFace
from PIL import Image
import tempfile
def save_temp_image(image_file):
"""Save uploaded image temporarily."""
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".jpg")
image = Image.open(image_file)
image.save(temp_file.name)
return temp_file.name
def match_faces(id_image, selfie_image):
"""Match faces using DeepFace."""
try:
id_image_path = save_temp_image(id_image)
selfie_path = save_temp_image(selfie_image)
result = DeepFace.verify(img1_path=id_image_path, img2_path=selfie_path, model_name="VGG-Face")
return result["verified"]
except Exception as e:
print("Face Matching Error:", e)
return False
|