-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfaces.py
More file actions
55 lines (32 loc) · 1.08 KB
/
faces.py
File metadata and controls
55 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import face_recognition
import requests
from io import BytesIO
from api import Api
from PIL import Image
import numpy as np
class Faces:
def __init__(self):
self.load()
def load(self):
print('LOADING FACES')
api = Api()
known_face_encodings = []
known_face_names = []
for face in api.data['faces']:
print('face:')
print(face)
response = requests.get(face['image'])
img = Image.open(BytesIO(response.content))
face_image = np.array(img)
face_encoding = face_recognition.face_encodings(face_image)[0]
known_face_encodings.append(face_encoding)
known_face_names.append(face)
img.close()
# Create arrays of known face encodings and their names
self.known_face_encodings = known_face_encodings
self.known_face_names = known_face_names
def getKnownFaceEncodings(self):
return self.known_face_encodings
def getKnownFaceNames(self):
return self.known_face_names
#x = Faces()