Tests: Generalize to Python 2 and 3. Run Python 2 by default.
This commit is contained in:
parent
71ee6ee747
commit
fe8f73eb69
|
@ -4,4 +4,4 @@ set -e
|
||||||
|
|
||||||
cd $(dirname $0)
|
cd $(dirname $0)
|
||||||
|
|
||||||
nosetests -v
|
nosetests-2.7 -v
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import sys
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
np.set_printoptions(precision=2)
|
np.set_printoptions(precision=2)
|
||||||
|
@ -40,7 +41,7 @@ def test_batch_represent():
|
||||||
|
|
||||||
workDir = tempfile.mkdtemp(prefix='OpenFaceBatchRep-')
|
workDir = tempfile.mkdtemp(prefix='OpenFaceBatchRep-')
|
||||||
|
|
||||||
cmd = ['python3', os.path.join(openfaceDir, 'util', 'align-dlib.py'),
|
cmd = [sys.executable, os.path.join(openfaceDir, 'util', 'align-dlib.py'),
|
||||||
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
|
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
|
||||||
os.path.join(workDir, 'aligned')]
|
os.path.join(workDir, 'aligned')]
|
||||||
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
||||||
|
@ -49,7 +50,7 @@ def test_batch_represent():
|
||||||
print(err)
|
print(err)
|
||||||
assert p.returncode == 0
|
assert p.returncode == 0
|
||||||
|
|
||||||
cmd = ['python3', os.path.join(openfaceDir, 'util', 'align-dlib.py'),
|
cmd = [sys.executable, os.path.join(openfaceDir, 'util', 'align-dlib.py'),
|
||||||
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
|
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
|
||||||
os.path.join(workDir, 'aligned')]
|
os.path.join(workDir, 'aligned')]
|
||||||
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
||||||
|
|
|
@ -19,6 +19,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import sys
|
||||||
|
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ lfwSubset = os.path.join(openfaceDir, 'data', 'lfw-subset')
|
||||||
|
|
||||||
|
|
||||||
def test_compare_demo():
|
def test_compare_demo():
|
||||||
cmd = ['python3', os.path.join(openfaceDir, 'demos', 'compare.py'),
|
cmd = [sys.executable, os.path.join(openfaceDir, 'demos', 'compare.py'),
|
||||||
os.path.join(exampleImages, 'lennon-1.jpg'),
|
os.path.join(exampleImages, 'lennon-1.jpg'),
|
||||||
os.path.join(exampleImages, 'lennon-2.jpg')]
|
os.path.join(exampleImages, 'lennon-2.jpg')]
|
||||||
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
||||||
|
@ -39,7 +40,7 @@ def test_compare_demo():
|
||||||
|
|
||||||
|
|
||||||
def test_classification_demo_pretrained():
|
def test_classification_demo_pretrained():
|
||||||
cmd = ['python3', os.path.join(openfaceDir, 'demos', 'classifier.py'),
|
cmd = [sys.executable, os.path.join(openfaceDir, 'demos', 'classifier.py'),
|
||||||
'infer',
|
'infer',
|
||||||
os.path.join(openfaceDir, 'models', 'openface',
|
os.path.join(openfaceDir, 'models', 'openface',
|
||||||
'celeb-classifier.nn4.small2.v1.pkl'),
|
'celeb-classifier.nn4.small2.v1.pkl'),
|
||||||
|
@ -52,7 +53,7 @@ def test_classification_demo_pretrained():
|
||||||
|
|
||||||
|
|
||||||
def test_classification_demo_pretrained_multi():
|
def test_classification_demo_pretrained_multi():
|
||||||
cmd = ['python3', os.path.join(openfaceDir, 'demos', 'classifier.py'),
|
cmd = [sys.executable, os.path.join(openfaceDir, 'demos', 'classifier.py'),
|
||||||
'infer', '--multi',
|
'infer', '--multi',
|
||||||
os.path.join(openfaceDir, 'models', 'openface',
|
os.path.join(openfaceDir, 'models', 'openface',
|
||||||
'celeb-classifier.nn4.small2.v1.pkl'),
|
'celeb-classifier.nn4.small2.v1.pkl'),
|
||||||
|
@ -70,7 +71,7 @@ def test_classification_demo_training():
|
||||||
|
|
||||||
workDir = tempfile.mkdtemp(prefix='OpenFaceCls-')
|
workDir = tempfile.mkdtemp(prefix='OpenFaceCls-')
|
||||||
|
|
||||||
cmd = ['python3', os.path.join(openfaceDir, 'util', 'align-dlib.py'),
|
cmd = [sys.executable, os.path.join(openfaceDir, 'util', 'align-dlib.py'),
|
||||||
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
|
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
|
||||||
os.path.join(workDir, 'aligned')]
|
os.path.join(workDir, 'aligned')]
|
||||||
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
||||||
|
@ -79,7 +80,7 @@ def test_classification_demo_training():
|
||||||
print(err)
|
print(err)
|
||||||
assert p.returncode == 0
|
assert p.returncode == 0
|
||||||
|
|
||||||
cmd = ['python3', os.path.join(openfaceDir, 'util', 'align-dlib.py'),
|
cmd = [sys.executable, os.path.join(openfaceDir, 'util', 'align-dlib.py'),
|
||||||
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
|
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
|
||||||
os.path.join(workDir, 'aligned')]
|
os.path.join(workDir, 'aligned')]
|
||||||
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
||||||
|
@ -97,7 +98,7 @@ def test_classification_demo_training():
|
||||||
print(err)
|
print(err)
|
||||||
assert p.returncode == 0
|
assert p.returncode == 0
|
||||||
|
|
||||||
cmd = ['python3', os.path.join(openfaceDir, 'demos', 'classifier.py'),
|
cmd = [sys.executable, os.path.join(openfaceDir, 'demos', 'classifier.py'),
|
||||||
'train',
|
'train',
|
||||||
os.path.join(workDir, 'reps')]
|
os.path.join(workDir, 'reps')]
|
||||||
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
||||||
|
@ -106,7 +107,7 @@ def test_classification_demo_training():
|
||||||
print(err)
|
print(err)
|
||||||
assert p.returncode == 0
|
assert p.returncode == 0
|
||||||
|
|
||||||
cmd = ['python3', os.path.join(openfaceDir, 'demos', 'classifier.py'),
|
cmd = [sys.executable, os.path.join(openfaceDir, 'demos', 'classifier.py'),
|
||||||
'infer',
|
'infer',
|
||||||
os.path.join(workDir, 'reps', 'classifier.pkl'),
|
os.path.join(workDir, 'reps', 'classifier.pkl'),
|
||||||
os.path.join(lfwSubset, 'raw', 'Adrien_Brody', 'Adrien_Brody_0001.jpg')]
|
os.path.join(lfwSubset, 'raw', 'Adrien_Brody', 'Adrien_Brody_0001.jpg')]
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import sys
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
np.set_printoptions(precision=2)
|
np.set_printoptions(precision=2)
|
||||||
|
@ -37,7 +38,7 @@ def test_dnn_training():
|
||||||
lfwSubset), "Get lfw-subset by running ./data/download-lfw-subset.sh"
|
lfwSubset), "Get lfw-subset by running ./data/download-lfw-subset.sh"
|
||||||
|
|
||||||
imgWorkDir = tempfile.mkdtemp(prefix='OpenFaceTrainingTest-Img-')
|
imgWorkDir = tempfile.mkdtemp(prefix='OpenFaceTrainingTest-Img-')
|
||||||
cmd = ['python3', os.path.join(openfaceDir, 'util', 'align-dlib.py'),
|
cmd = [sys.executable, os.path.join(openfaceDir, 'util', 'align-dlib.py'),
|
||||||
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
|
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
|
||||||
os.path.join(imgWorkDir, 'aligned')]
|
os.path.join(imgWorkDir, 'aligned')]
|
||||||
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
||||||
|
@ -46,7 +47,7 @@ def test_dnn_training():
|
||||||
print(err)
|
print(err)
|
||||||
assert p.returncode == 0
|
assert p.returncode == 0
|
||||||
|
|
||||||
cmd = ['python3', os.path.join(openfaceDir, 'util', 'align-dlib.py'),
|
cmd = [sys.executable, os.path.join(openfaceDir, 'util', 'align-dlib.py'),
|
||||||
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
|
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
|
||||||
os.path.join(imgWorkDir, 'aligned')]
|
os.path.join(imgWorkDir, 'aligned')]
|
||||||
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
||||||
|
|
Loading…
Reference in New Issue