1 Star 0 Fork 1

sychen/CVPR19-Face-Anti-spoofing

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
submission.py 2.49 KB
一键复制 编辑 原始数据 按行查看 历史
Tao Shen 提交于 2019-03-17 18:04 . fix
from metric import *
from process.data_fusion import *
def load_sub(sub):
sub_dict = {}
f = open(sub,'r')
lines = f.readlines()
for line in lines:
line = line.strip()
line = line.split(' ')
sub_dict[line[0]] = float(line[3])
return sub_dict
def ensemble_test_dir(sub_dir_list, save_name):
dict_list = []
for sub_dir in sub_dir_list:
for sub in os.listdir(sub_dir):
if '.txt' in sub:
sub_dict = load_sub(os.path.join(sub_dir,sub))
dict_list.append(sub_dict)
test_list = load_test_list()
probs = []
for name,_,_ in test_list:
prob_tmp = 0.0
for sub_dict in dict_list:
prob_tmp += sub_dict[name] / (len(dict_list)*1.0)
probs.append(prob_tmp)
probs = np.asarray(probs)
submission(probs,save_name, mode='test')
def sub_first():
dir = r'./models/'
dir_list = [dir + r'baseline_fusion_32/checkpoint/global_test_36_TTA',
dir + r'baseline_fusion_48/checkpoint/global_test_36_TTA',
dir + r'baseline_fusion_64/checkpoint/global_test_36_TTA',
dir + r'model_A_color_48/checkpoint/global_test_36_TTA',
dir + r'model_A_depth_48/checkpoint/global_test_36_TTA',
dir + r'model_A_ir_48/checkpoint/global_test_36_TTA']
ensemble_test_dir(dir_list, 'test_first.txt')
print('test_first.txt done!')
def sub_second():
dir = r'./models/'
dir_list = [dir + r'model_A_color_48/checkpoint/global_test_36_TTA',
dir + r'model_A_depth_48/checkpoint/global_test_36_TTA',
dir + r'model_A_ir_48/checkpoint/global_test_36_TTA',
dir + r'model_A_color_48/checkpoint/global_test_36_TTA',
dir + r'model_A_depth_48/checkpoint/global_test_36_TTA',
dir + r'model_A_ir_48/checkpoint/global_test_36_TTA',
dir + r'model_A_color_32/checkpoint/global_test_36_TTA',
dir + r'model_A_depth_32/checkpoint/global_test_36_TTA',
dir + r'model_A_ir_32/checkpoint/global_test_36_TTA',
dir + r'model_A_color_64/checkpoint/global_test_36_TTA',
dir + r'model_A_depth_64/checkpoint/global_test_36_TTA',
dir + r'model_A_ir_64/checkpoint/global_test_36_TTA',]
ensemble_test_dir(dir_list, 'test_second.txt')
print('test_second.txt done!')
if __name__ == '__main__':
sub_first() #TPR@FPR=10e-4 0.9971
sub_second() #TPR@FPR=10e-4 0.9991
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/uestc-sychen/CVPR19-Face-Anti-spoofing.git
git@gitee.com:uestc-sychen/CVPR19-Face-Anti-spoofing.git
uestc-sychen
CVPR19-Face-Anti-spoofing
CVPR19-Face-Anti-spoofing
master

搜索帮助