forked from saideeptalari/Face-Recognition
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.py
More file actions
25 lines (21 loc) · 668 Bytes
/
Copy pathdb.py
File metadata and controls
25 lines (21 loc) · 668 Bytes
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
import numpy as np
import pickle
def add_embeddings(embedding, label,
embeddings_path="face_embeddings.npy",
labels_path="labels.pickle"):
first_time = False
try:
embeddings = np.load(embeddings_path)
labels = pickle.load(open(labels_path, 'rb'))
except IOError:
first_time = True
if first_time:
embeddings = embedding
labels = [label]
else:
embeddings = np.concatenate([embeddings, embedding], axis=0)
labels.append(label)
np.save(embeddings_path, embeddings)
with open(labels_path, "wb") as f:
pickle.dump(labels, f)
return True