Carson1

Untitled

Jul 28th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. import face_recognition
  2. import glob
  3.  
  4. known_faces_encodings = dict()
  5. test_image_encodings = []
  6. quantity_faces = []
  7. result = []
  8.  
  9. for i in glob.glob("/home/alexandr/PycharmProjects/chatbot/photos/*.jpg"):
  10.     photo = face_recognition.load_image_file(i)
  11.     known_faces_encodings[i] = face_recognition.face_encodings(photo)[0]
  12.  
  13. for i in glob.glob("/home/alexandr/PycharmProjects/chatbot/vkphotos/*.jpg"):
  14.     test_image = face_recognition.load_image_file(i)
  15.     test_image_locations = face_recognition.face_locations(test_image)
  16.     test_image_encoding = face_recognition.face_encodings(test_image, test_image_locations)[0]
  17.     test_image_encodings.append(test_image_encoding)
  18.     quantity_faces.append(test_image_locations)
  19.  
  20. if not quantity_faces == []:
  21.     for i in known_faces_encodings.keys():
  22.         for j in test_image_encodings:
  23.             comparing = face_recognition.compare_faces([known_faces_encodings[i]], j)[0]
  24.             if comparing:
  25.                 result.append(i)
  26.                 print(i)
  27.             else:
  28.                 print('Не найденно похожего лица')
  29. else:
  30.     print('На этих фотографиях не найдено лиц')
Advertisement
Add Comment
Please, Sign In to add comment