Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import face_recognition
- import glob
- known_faces_encodings = dict()
- test_image_encodings = []
- quantity_faces = []
- result = []
- for i in glob.glob("/home/alexandr/PycharmProjects/chatbot/photos/*.jpg"):
- photo = face_recognition.load_image_file(i)
- known_faces_encodings[i] = face_recognition.face_encodings(photo)[0]
- for i in glob.glob("/home/alexandr/PycharmProjects/chatbot/vkphotos/*.jpg"):
- test_image = face_recognition.load_image_file(i)
- test_image_locations = face_recognition.face_locations(test_image)
- test_image_encoding = face_recognition.face_encodings(test_image, test_image_locations)[0]
- test_image_encodings.append(test_image_encoding)
- quantity_faces.append(test_image_locations)
- if not quantity_faces == []:
- for i in known_faces_encodings.keys():
- for j in test_image_encodings:
- comparing = face_recognition.compare_faces([known_faces_encodings[i]], j)[0]
- if comparing:
- result.append(i)
- print(i)
- else:
- print('Не найденно похожего лица')
- else:
- print('На этих фотографиях не найдено лиц')
Advertisement
Add Comment
Please, Sign In to add comment