Skip to content

Instantly share code, notes, and snippets.

@vimalvnair
Created April 17, 2019 06:53
Show Gist options
  • Save vimalvnair/d57ae8b48d0b0b9c57dc328685995d91 to your computer and use it in GitHub Desktop.
Save vimalvnair/d57ae8b48d0b0b9c57dc328685995d91 to your computer and use it in GitHub Desktop.
image_match
# import the libraries
import os
import face_recognition
# make a list of all the available images
images = os.listdir('images-reg')
# load your image
image_to_be_matched = face_recognition.load_image_file('George.jpg')
# encoded the loaded image into a feature vector
image_to_be_matched_encoded = face_recognition.face_encodings(image_to_be_matched)[0]
for image in images:
# load the image
current_image = face_recognition.load_image_file("images-reg/" + image)
# encode the loaded image into a feature vector
current_image_encoded = face_recognition.face_encodings(current_image)[0]
# match your image with the image and check if it matches
result = face_recognition.compare_faces([image_to_be_matched_encoded], current_image_encoded)
# check if it was a match
if result[0] == True:
print("Matched: " + image)
else:
print("Not matched: " + image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment