forked from choucavalier/facedetect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
train.py
executable file
·46 lines (37 loc) · 1.28 KB
/
train.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
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
import os
import sys
import subprocess
import glob
def check_build():
if not os.path.exists("build/"):
return False
if not os.path.exists("build/build_options.txt"):
return False
build_options_file = open('build/build_options.txt', 'r+')
rawlines = build_options_file.readlines()
lines = []
for line in rawlines:
lines.append(line.rstrip('\n'))
if "training" not in lines:
return False
if "preprocessing" not in lines:
return False
return True
if not os.path.exists("checkpoints"):
os.makedirs("checkpoints")
if not check_build():
subprocess.check_call(["./compile.py"])
if not os.path.exists("data"):
subprocess.check_call(["./configure.sh"])
else:
if not os.path.exists("data/positive"):
subprocess.check_call(["mkdir", "data/positive"])
subprocess.check_call(["./build/preprocess"])
subprocess.check_call(["rm", "-rf", "data/lfwcrop_grey/"])
cascades = list(glob.iglob('checkpoints/*.dat'))
if len(cascades) > 0:
most_recent_cascade = max(cascades, key=os.path.getctime)
subprocess.check_call(["./build/train", "data/positive", "data/negative", most_recent_cascade])
else:
subprocess.check_call(["./build/train", "data/positive", "data/negative"])