Skip to content

Commit c6cf22e

Browse files
committed
Add weeks/2018_06_01/test.txt
1 parent dafe08a commit c6cf22e

8 files changed

+991
-3
lines changed

D:\output.xls

13.5 KB
Binary file not shown.

__pycache__/count.cpython-35.pyc

6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.

__pycache__/servers.cpython-35.pyc

6 Bytes
Binary file not shown.

count.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python3
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33
# Author: xurongzhong#126.com wechat:pythontesting qq:37391319
44
# CreateDate: 2018-1-8

tools/run_server.py

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import time
1111
import re
1212

13-
import massedit
14-
1513
import data_common
1614
import servers
1715
import count

tools/xiaomi_rename.py

+242
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
#!/usr/bin/python3
2+
# -*- coding: utf-8 -*-
3+
# Author: xurongzhong#126.com
4+
# CreateDate: 2018-3-31
5+
6+
import argparse
7+
import shutil
8+
import os
9+
import subprocess
10+
import time
11+
import re
12+
13+
import data_common
14+
import servers
15+
import count
16+
import numpy as np
17+
18+
description = '''
19+
20+
功能:执行比对测试
21+
22+
活体示例:
23+
python3 run_server.py liveness -t batch1.7.5
24+
python3 run_server.py liveness -t batch1.7.6
25+
python3 run_server.py liveness -t base
26+
python3 run_server.py liveness -t bug
27+
28+
gaze示例:
29+
python3 run_server.py gaze -t little -w -b /opt/test_tools/faceunlock_test_general_meil
30+
31+
32+
landmark示例:
33+
$ python3 run_server.py landmark -d /home/andrew/code/tmp/sensetime -w
34+
35+
比对示例:
36+
37+
$ python3 run_server.py verify -w -d /home/andrew/code/data/common/verify/china_500 -e jpg
38+
$ python3 run_server.py verify -w -t vivo-verify-100
39+
$ python3 run_server.py verify -w -d /home/andrew/code/data/common/verify/india_32/ -e yuv
40+
41+
测试工具的目录:
42+
活体:/opt/test_tools/faceunlock_test_general_meil
43+
其他:/opt/test_tools/base/faceunlock_test_general_meil,即默认目录。
44+
'''
45+
46+
parser = argparse.ArgumentParser(description=description,
47+
formatter_class=argparse.RawTextHelpFormatter)
48+
parser.add_argument('test_type', action="store", help=u'测试类型')
49+
parser.add_argument('-d', action='store', dest='directory', default=None,
50+
help='数据集目录')
51+
parser.add_argument('-b', action='store', dest='base',
52+
default='/opt/test_tools/base/faceunlock_test_general_meil',
53+
help='比对工具目录, 默认为/opt/test_tools/base/faceunlock_test_general_meil')
54+
parser.add_argument('-e', action='store', dest='ext', default='',
55+
help='文件扩展名,默认为ir')
56+
parser.add_argument('-t', action='store', dest='data_type', default='',
57+
help='数据集类型')
58+
parser.add_argument('-w', action="store_true", default=False, help=u'是否等待结束')
59+
parser.add_argument('-o', action='store', dest='output', default='output',
60+
help='输出目录')
61+
parser.add_argument('--version', action='version',
62+
version='%(prog)s 1.0 Rongzhong xu 2018 04 26')
63+
options = parser.parse_args()
64+
65+
types = {
66+
"verify": {
67+
'name': 'verify',
68+
'process': 'sample_verify',
69+
'cmd':"nohup ./run -r output/i_enroll.txt output/i_real.txt > verify.log 2>&1 &",
70+
'vivo-verify-100':'/home/andrew/code/data/tof/base_test_data/vivo-verify-100',
71+
'vivo-verify-452':'/home/andrew/code/data/tof/base_test_data/vivo-verify-452',
72+
'vivo-verify-611':'/home/andrew/code/data/tof/base_test_data/vivo-verify-611',
73+
'little':'/home/andrew/code/data/tof/little_test_data/little_verify',
74+
'bug':'/home/andrew/code/data/tof/bug/verify',
75+
'file_type':'ir',
76+
},
77+
"gaze": {
78+
'file_type':'ir',
79+
'name': 'gaze_mn',
80+
'process': 'sample_gaze_mn',
81+
'flag':'/gaze/',
82+
'cmd':"nohup ./run -f output/files.txt > gaze.log 2>&1 &",
83+
#'base':'/home/andrew/code/data/tof/base_test_data/vivo-gaze/20180418_a.m.-gaze',
84+
'base':'/home/andrew/code/data/tof/base_test_data/vivo-gaze',
85+
'little':'/home/andrew/code/data/tof/little_test_data/little_gaze',
86+
'bug':'/home/andrew/code/data/tof/bug/gaze',
87+
'nocase':'/home/andrew/code/data/tof/vivo3D_batch_test/gaze_batch/nocase(0423_0430_false2.2)',
88+
'case':'/home/andrew/code/data/tof/vivo3D_batch_test/gaze_batch/0418_0419_0501_case',
89+
'demo1.7.8':'/home/andrew/code/data/tof/vivo3D_batch_test/gaze_batch/demo_1.7.8--gaze_2.6.0_ceshi_20180430',
90+
},
91+
92+
"liveness": {
93+
'file_type':'ir,depth',
94+
'name': 'liveness',
95+
'process': 'sample_liveness',
96+
'flag':'photo/',
97+
'cmd': "nohup ./run -l output/files.txt > live.log 2>&1 & ",
98+
'bug':"/home/andrew/code/data/tof/bug/liveness",
99+
'base':'/home/andrew/code/data/tof/base_test_data/vivo-liveness',
100+
'batch1.7.5':'/home/andrew/code/data/tof/vivo3D_batch_test/liveness_batch/demo_1.7.5_test',
101+
'batch1.7.6':'/home/andrew/code/data/tof/vivo3D_batch_test/liveness_batch/demo_1.7.6_test',
102+
'batch1.7.7':'/home/andrew/code/data/tof/vivo3D_batch_test/demo_1.7.7_test',
103+
'little':'/home/andrew/code/data/tof/little_test_data/little_hacker',
104+
},
105+
106+
"landmark":{
107+
'file_type':'ir',
108+
'name': 'detect',
109+
'process': 'sample_align',
110+
'flag':'/little_photo/',
111+
'cmd':"nohup ./run -m output/files.txt > landmark.log 2>&1 &",
112+
},
113+
}
114+
115+
tool = options.base
116+
now = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime())
117+
if options.directory is None:
118+
if not options.data_type:
119+
print("data_type不能为空")
120+
exit(1)
121+
options.directory = types[options.test_type][options.data_type]
122+
123+
file_name = "{}{}{}".format(tool, os.sep, "output/files.txt")
124+
label_name = "{}{}{}".format(tool, os.sep, "output/labels.txt")
125+
config_name = "{}{}{}".format(tool, os.sep, "config.json")
126+
127+
128+
if options.ext:
129+
types[options.test_type]['file_type'] = options.ext
130+
131+
if options.test_type != 'verify':
132+
data_common.get_filelistandlabel(
133+
options.directory,
134+
types[options.test_type]['flag'],
135+
filetype=types[options.test_type]['file_type'],
136+
file_name=file_name,
137+
label_name=label_name)
138+
else:
139+
file_name = "{}{}{}".format(tool, os.sep, "output/i_real.txt")
140+
servers.build_verify_input(options.directory, tool + '/output',
141+
filetype=types[options.test_type]['file_type'])
142+
143+
configs = open(config_name).read()
144+
145+
search = re.search('{0}.*?(\d+.\d+.\d+)'.format(types[options.test_type]['name']),
146+
configs)
147+
if not search:
148+
print("Error: Can not find version!")
149+
exit(1)
150+
version = search.group(1)
151+
print(types[options.test_type]['name'], version)
152+
cmd1 = "cd {}".format(tool)
153+
directory = "{0}{1}result{1}{2}-{3}-{4}-{5}".format(
154+
tool, os.sep, options.test_type, now, options.data_type, version)
155+
data_common.check_directory(directory)
156+
shutil.copyfile(file_name,
157+
"{}{}{}".format(directory, os.sep,os.path.basename(file_name)))
158+
shutil.copyfile(label_name,
159+
"{}{}{}".format(directory, os.sep,os.path.basename(label_name)))
160+
shutil.copyfile(config_name,
161+
"{}{}{}".format(directory, os.sep,os.path.basename(config_name)))
162+
163+
cmd = "{} && {}".format(cmd1,types[options.test_type]['cmd'])
164+
print(cmd)
165+
subprocess.call(cmd,shell=True)
166+
167+
time.sleep(5)
168+
169+
print("Please see result in {}".format(directory))
170+
171+
# wait for result
172+
if not options.w:
173+
exit(0)
174+
175+
176+
# anlyse result
177+
result = "{0}{1}{2}{1}{2}_output%files.txt.csv".format(
178+
tool, os.sep, options.test_type)
179+
if options.test_type == 'verify':
180+
result = "{0}{1}{2}{1}{2}_score_output%i_enroll.txt.csv".format(
181+
tool, os.sep, options.test_type)
182+
print(result)
183+
servers.wait_until_stop('sample')
184+
185+
time.sleep(3)
186+
187+
new_result = "{0}{1}{2}-result.csv".format(directory, os.sep, version)
188+
print(result)
189+
print(new_result)
190+
shutil.copyfile(result, new_result)
191+
error_name = "{0}{1}{2}----result.xlsx".format(directory, os.sep, version)
192+
193+
if options.test_type != 'verify':
194+
values = "{0}{1}{2}-values.csv".format(directory, os.sep, version)
195+
maps = data_common.concat_file(new_result, file_name, sep=',')
196+
data_common.output_file(values, maps)
197+
198+
if options.test_type == 'liveness':
199+
new_result_ = "{0}{1}{2}-result_.csv".format(directory, os.sep, version)
200+
shutil.copyfile(result, new_result_)
201+
cmd = "sed -i 's#-1#1#' {}".format(new_result_)
202+
subprocess.call(cmd,shell=True)
203+
time.sleep(3)
204+
205+
if options.data_type == 'base':
206+
replace = '/home/andrew/code/data/tof/base_test_data/vivo-liveness/'
207+
else:
208+
replace = ''
209+
servers.get_liveness_server_result(new_result, file_name, label_name,
210+
replace=replace, error_name=error_name, type_=options.data_type)
211+
212+
roc = "{0}{1}{2}-roc.txt".format(directory, os.sep, version)
213+
fprs = np.arange(0.10, 0, -0.01)
214+
count.roc(new_result_, label_name, output=roc, fprs=fprs)
215+
216+
if options.test_type == 'gaze':
217+
fprs = [0.3,0.25,0.2,0.15,0.1,0.05,0.02,0.01,0.001]
218+
roc = "{0}{1}{2}-roc.txt".format(directory, os.sep, version)
219+
count.roc(result, label_name, fprs=fprs, output=roc, )
220+
servers.get_gaze_server_result(new_result, file_name, label_name,
221+
error_name=error_name, type_=options.data_type)
222+
223+
224+
if options.test_type == 'verify':
225+
person_name = "{}{}{}".format(tool, os.sep, "output/i_enroll.txt")
226+
print(person_name)
227+
shutil.copyfile(person_name,
228+
"{}{}{}".format(directory, os.sep, os.path.basename(person_name)))
229+
roc = "{0}{1}{2}-roc.txt".format(directory, os.sep, version)
230+
count.verify_roc(result, label_name, output=roc, )
231+
232+
servers.get_verify_server_result(
233+
person_name, file_name, new_result,
234+
replace_file=options.directory.rstrip(os.sep) + os.sep,
235+
replace_name=options.base + '/output/enroll_list/',
236+
error_name=error_name,
237+
)
238+
239+
240+
241+
242+

0 commit comments

Comments
 (0)