-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain_model.py
More file actions
30 lines (22 loc) · 913 Bytes
/
train_model.py
File metadata and controls
30 lines (22 loc) · 913 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
26
27
28
29
30
# python train_model.py --embeddings output/embeddings.pickle \
# --recognizer output/recognizer.pickle --le output/le.pickle
from sklearn.svm import SVC
import argparse
import pickle
import numpy as np
# Modificar las siguientes variables al gusto del directorio montado
embed_path = "resources/pickle/embeddings.pickle"
recognizer_path = "resources/pickle/recognizer.pickle"
# load the face embeddings
data = pickle.loads(open(embed_path, "rb").read())
labels = data["names"]
# train the model used to accept the 128-d embeddings of the face and
# then produce the actual face recognition
print("Entrenando al modelo...")
recognizer = SVC(C=1.0, kernel="linear", probability=True)
np_labels = np.array(labels)
recognizer.fit(data["embeddings"], np_labels)
# write the actual face recognition model to disk
with open(recognizer_path, "wb") as f:
f.write(pickle.dumps(recognizer))
print("Saliendo..")