-
Notifications
You must be signed in to change notification settings - Fork 1
/
trainFLD.py
36 lines (29 loc) · 1.21 KB
/
trainFLD.py
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
import os
import dlib
fldDataDir = "facial_landmark_data"
numPoints = 70
modelName = "predictor_" + str(numPoints) + "_face_landmarks.dat"
options = dlib.shape_predictor_training_options()
options.cascade_depth = 10
options.num_trees_per_cascade_level = 500
options.tree_depth = 4
options.nu = 0.1
options.oversampling_amount = 20
options.feature_pool_size = 400
options.feature_pool_region_padding = 0
options.lambda_param = 0.1
options.num_test_splits = 20
options.be_verbose = True
trainingXMLPath = os.path.join(fldDataDir, "train_face_landmarks_70.xml")
testingXMLPath = os.path.join(fldDataDir, "test_face_landmarks_70.xml")
outputModelPath = os.path.join(fldDataDir, modelName)
print("entering")
if(os.path.exists(trainingXMLPath) and os.path.exists(testingXMLPath)):
dlib.train_shape_predictor(trainingXMLPath, outputModelPath, options)
print("\nTraining Accuracy: {}".format(dlib.test_shape_predictor(trainingXMLPath, outputModelPath)))
print("\nTesting Accuracy: {}".format(dlib.test_shape_predictor(testingXMLPath, outputModelPath)))
else:
print('training and test XML files not found.')
print('Please check paths:')
print('train: {}'.format(trainingXmlPath))
print('test: {}'.format(testingXmlPath))